npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@theo-dev/airtable-connect

v0.2.32

Published

A simple way to manage your Airtable connection

Downloads

26

Readme

Airtable Configuration

This package is used to configure the Airtable integration for your project.

New Features!

In this version, you can now use readByID function to get a record by ID. I work on a new version to add more features. If you have any suggestions, please contact me.

Getting Started

Installation

npm install --save @theo-dev/airtable-connect

Create a .env file in the root of your project and add the following:

# If you use React, you can add the following to your .env file
REACT_APP_AIRTABLE_PERSONNAL_TOKEN=
REACT_APP_AIRTABLE_BASE_ID=

# If you use Vite, you can add the following to your .env file
VITE_AIRTABLE_PERSONNAL_TOKEN=
VITE_AIRTABLE_BASE_ID=

 

Usage

  • Connection to Airtable

    // If you create a .env file, you can use the following code to connect to Airtable
    import { AirtableConnect } from "@theo-dev/airtable-connect";
    
    const { AirtableData } = AirtableConnect;
    
    const tableInstance = new AirtableData(
      "Table Name",
      "View Name (optional if you want to use the default view)"
    );
    // If you don't create a .env file, you can use the following code to connect to Airtable
    import { AirtableConnect } from "@theo-dev/airtable-connect";
    
    const { AirtableConfig, AirtableData } = AirtableConnect;
    
    AirtableConfig.getBase("Personnal Token", "Base ID");
    
    const tableInstance = new AirtableData(
      "Table Name",
      "View Name (optional if you want to use the default view)"
    );
  • Retrieving Datas

    Add function in parameter of read function to get datas like this:

    let datas = [];
    
    tableInstance.read({
      action: (dataset) => {
        datas = dataset;
      },
      completedOnly: true, // optional - if you want to get only completed records
    });
  • Retrieving data by ID

    Add function in parameter of readByID function to get data like this:

    let data = null;
    
    tableInstance.readByID({
      id: "RECORD_ID",
      action: (dataset) => {
        data = dataset;
      },
    });
  • Creating Data

    // Create a record
    
    tableInstance.create({
      datas: { "Field Name": "Field Value" },
    }); // return nothing just create the record

    You can also add function in parameter of create function to get the data like this:

    let newRecord = [];
    
    tableInstance.create({
      datas: { "Field Name": "Field Value" },
      action: (record) => {
        newRecord = record;
      },
    }); // return nothing just create the record and add the new record in newRecord variable
  • Updating Data

    // Update a record
    tableInstance.update({
      datas: { id: "ExampleID", fields: { FieldName: "Field Value" } },
    }); // return nothing just update the record
    
    // Update multiple records
    
    const records = [
      {
        id: "ExampleID",
        fields: { FieldName: "Field Value" },
      },
      {
        id: "ExampleID",
        fields: { FieldName: "Field Value" },
      },
    ];
    
    tableInstance.update({
      datas: records,
    }); // return nothing just update records

    You can also add function in parameter of update function to get the data like this:

    let updatedRecord = [];
    
    tableInstance.update({
      datas: { id: "ExampleID", fields: { FieldName: "Field Value" } },
      action: (record) => {
        updatedRecord = record;
      },
    });
  • Deleting Data

    Add function in parameter of delete function to get the deleted data like this:

    let deletedRecord = [];
    
    tableInstance.delete({
      id: "ExampleID",
      action: (record) => {
        deletedRecord = record;
      },
    });

Package Dependencies

Airtable TypeScript

Credits