Options
Menu

Class AirtablePlusPlus<IFields>

An AirtablePlusPlus instance. Y'know, the thing you're here for.

Type parameters

  • IFields: Record<string, unknown>

    An interface to describe how your data is formatted.

Hierarchy

  • AirtablePlusPlus

Index

Constructors

constructor

  • Creates an AirtablePlusPlus instance, representing a table. The configuration options you provide here may be overriden later

    example

    const inst = new AirtablePlus({ apiKey: 'key001zdhiyfvg553 baseID: 'xxx', tableName: 'Table 1' });

    Type parameters

    • IFields: Record<string, unknown>

    Parameters

    Returns AirtablePlusPlus<IFields>

Properties

table

table: Table

Methods

create

  • Creates a new row using the supplied data object as row values. The object must contain valid keys that correspond to the name and data type of the Airtable table schema being written into, else it will throw an error.

    example

    const res = await inst.create({ "First Name": 'foo' });

    Parameters

    • data: Partial<IFields>

      Create data object

    Returns Promise<AirtablePlusPlusRecord<IFields>>

    an array of created records

  • Creates rows using the supplied data objects as row values. The objects must contain valid keys that correspond to the name and data type of the Airtable table schema being written into, else it will throw an error.

    example

    const res = await inst.create([{ "First Name": 'foo' }, { "First Name": 'bar' }]);

    Parameters

    • data: Partial<IFields>[]

      Array of data objects

    Returns Promise<AirtablePlusPlusRecord<IFields>[]>

    Created Record Object

delete

  • delete(rowID: string | string[]): Promise<object[] | object>
  • Deletes a row in the provided table

    example

    const res = await inst.delete('1234');

    Parameters

    • rowID: string | string[]

      Either an array of Airtable Row IDs or a single Airtable Row ID to delete

    Returns Promise<object[] | object>

    Deleted Record object(s)

deleteWhere

  • deleteWhere(where: string): Promise<Promise<object[] | object>[]>
  • Performs a bulk delete based on a search criteria. The criteria must be formatted in the valid Airtable formula syntax (see Airtable API docs)

    example

    const res = await inst.deleteWhere('firstName = "foo"');

    Parameters

    • where: string

      filterByFormula string to filter table data by

    Returns Promise<Promise<object[] | object>[]>

    Array of record objects

get

  • Get data for a specific row on Airtable

    example

    const res = await inst.get('rec1234');

    Parameters

    • rowID: string

      the internal Airtable Row ID to query data from

    Returns Promise<AirtablePlusPlusRecord<IFields>>

    Record object

read

  • Read all data from a table. Can be passed api options for filtering and sorting (see Airtable API docs). An optional transform function can be passed in to manipulate the rows as they are being read in.

    example

    const res = await inst.read();

    example

    const res = await inst.read({ maxRecords: 1 });

    Parameters

    • Optional params: QueryParams

      Airtable api parameters

    Returns Promise<AirtablePlusPlusRecord<IFields>[]>

    Array of record objects

replace

  • Bulk replaces given rows in airtable. Similar to the update function, the only difference is this will completely overwrite the rows. Any cells not passed in will be deleted from source row.

    example

    const res = await inst.replace([{ id: 'rec001', fields: {"First Name": "Zfogg"}}]);

    Parameters

    • data: object[]

      row data with keys that you'd like to replace

    Returns Promise<AirtablePlusPlusRecord<IFields>[]>

    Record object

  • Replaces a given row in airtable. Similar to the update function, the only difference is this will completely overwrite the row. Any cells not passed in will be deleted from source row.

    example

    const res = await inst.replace('rec001', { "First Name": "Zfogg" });

    Parameters

    • rowID: string

      Airtable Row ID to replace

    • data: IFields

      row data with keys that you'd like to replace

    Returns Promise<AirtablePlusPlusRecord<IFields>>

    Record object

replaceWhere

  • Performs a bulk replace based on a given search criteria. The criteria must be formatted in the valid Airtable formula syntax (see Airtable API docs)

    example

    const res = await inst.replaceWhere('firstName = "foo"', { firstName: 'fooBar' });

    Parameters

    • where: string

      filterByFormula string to filter table data by

    • data: IFields

      Data to replace if where condition is met

    Returns Promise<Promise<AirtablePlusPlusRecord<IFields>>[]>

    Array of record objects

update

  • Updates multiple rows in Airtable. Unlike the replace method anything not passed into the update data object still will be retained. You must send in an object with the keys in the same casing as the Airtable table columns.

    example

    const res = await inst.update([{id: 'rec1234567', fields: {"First Name": "Zfogg"}}]);

    Parameters

    • data: object[]

      Bulk update data. recordId is the internal Airtable Row Id. Fields is the row data with keys that you'd like to update

    Returns Promise<AirtablePlusPlusRecord<IFields>[]>

    Array of record objects

  • Updates a row in Airtable. Unlike the replace method anything not passed into the update data object still will be retained. You must send in an object with the keys in the same casing as the Airtable table columns.

    example

    const res = await inst.update('rec98765432', { "First Name": "Zfogg" });

    Parameters

    • rowID: string

      Airtable Row ID to update

    • data: Partial<IFields>

      row data with keys that you'd like to update

    Returns Promise<AirtablePlusPlusRecord<IFields>>

    Array of record objects

updateWhere

  • Performs a bulk update based on a search criteria. The criteria must be formatted in the valid Airtable formula syntax (see Airtable API docs)

    example

    const res = await inst.updateWhere('firstName = "foo"', { firstName: 'Zefogg' });

    Parameters

    • where: string

      filterByFormula string to filter table data by

    • data: Partial<IFields>

      Data to update if where condition is met

    Returns Promise<AirtablePlusPlusRecord<IFields>[]>

    Array of record objects

upsert

  • Attempts to upsert based on passed in primary key. Inserts if a new entry or updates if entry is already found

    example

    const res = await inst.upsert('primarKeyID', data);

    Parameters

    • key: string

      The column you want to use as a unique ID.

    • data: Partial<IFields>

      Updated data. Make sure to include the key you specified above alongside a value that will be used as the primary key If multiple entries are found with the same primary key, all of them will be updated

    Returns Promise<AirtablePlusPlusRecord<IFields>>

    Array of record objects

  • Parameters

    • key: string
    • data: Partial<IFields>[]

    Returns Promise<AirtablePlusPlusRecord<IFields>[]>

Generated using TypeDoc