Socket
Socket
Sign inDemoInstall

@theo-gillet/airtable-connect

Package Overview
Dependencies
14
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @theo-gillet/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.

Getting Started

Installation

npm install --save airtable-connect

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

# If you use NodeJS or VanillaJS, you can add the following to your .env file
AIRTABLE_API_KEY=
AIRTABLE_BASE_ID=

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

 

Usage

  • Connection to Airtable

    import airtableConnect from 'airtable-connect'
    
    
    // If project is using React, NodeJS or VanillaJS, you can use the following to load the environment variables
    
    const { AirtableConfig, AirtableData } = airtableConnect
    
    const example = new AirtableData('Table Name', 'View Name (optional if you want to use the default view)')
    
    // Else you can use the following to load the environment variables
    AirtableConfig.getBase('API Key', 'Base ID')
    
    const { AirtableData } = airtableConnect
    
    const example = new AirtableData('Table Name', 'View Name (optional if you want to use the default view)')
    
    
  • Retrieving Data

    // Retrieve all records
    
    example.read() // return dataset
    

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

    let data = []
    
    example.read((dataset) => {
        data = dataset
    })
    
  • Creating Data

    // Create a record
    
    example.create({ 'Field Name': 'Field Value' }) // return dataset
    

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

    let newRecord = []
    
    example.create({ 'Field Name': 'Field Value' }, (record) => {
        newRecord = record
    })
    
  • Updating Data

    // Update a record
    example.update({'id': 'ExampleID', 'fields': {'FieldName': 'Field Value'}}) // return dataset
    
    // Update multiple records
    
    const records = [
        {
            'id': 'ExampleID', 
            'fields': {'FieldName': 'Field Value'}
        }, 
        {
            'id': 'ExampleID', 
            'fields': {'FieldName': 'Field Value'}
        }
    ]
    
    example.update(records) // return dataset
    

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

    let updatedRecord = []
    
    example.update({'id': 'ExampleID', 'fields': {'FieldName': 'Field Value'}}, (record) => {
        updatedRecord = record
    })
    
  • Deleting Data

    // Delete a record
    
    example.delete('ExampleID') // return deleted data
    

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

    
    let deletedRecord = []
    
    example.delete('ExampleID', (record) => {
        deletedRecord = record
    })
    

Package Dependencies

Airtable

Credits

  • Author - Théo Gillet

Keywords

FAQs

Last updated on 19 Jan 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