This is alternative to the largely undocumented, and slightly unconventional, official client. This library is heavily inspired by the official client.
npm install @kyeotic/airtable
const { Client } = require('@kyeotic/airtable')
const client = new Client({
apiKey: string,
baseUrl: string
})
const myTable = client.base(baseId).table(tableName)
let query = myTable.query({ view: 'Grid View' })
// --- Paging ---
// AsyncIterator paging
for await (let page of query()) {
console.log(page) /* {
records: [Record],
offset: string
}*/
}
// Auto paging
let records = await query.all()
// Stream paging
await query.eachPage(async page => {
await processPage(page.records)
})
// --- CRUD ---
/* Record: {
id: string,
fields: {},
createdOn: Datetime
} */
let dbItem = await myTable.get(recordId)
let newItem = await myTable.create(record)
let updated = await myTable.update({ ...newItem.fields, name: 'updated' })
await myTable.delete(recordId)
The Typedoc generated docs are hosted here