Socket
Socket
Sign inDemoInstall

@theo-dev/airtable-connect

Package Overview
Dependencies
1
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @theo-dev/airtable-connect

A simple way to manage your Airtable connection


Version published
Maintainers
1
Created

Readme

Source

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

Keywords

FAQs

Last updated on 12 Oct 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc