grikomsn / airtable-deno

Unofficial Airtable client for Deno đŸ¦•
https://deno.land/x/airtable
MIT License
16 stars 8 forks source link
airtable airtable-api deno
![airtable-deno](https://raw.githubusercontent.com/grikomsn/airtable-deno/master/header.png) ![release](https://badgen.net/github/release/grikomsn/airtable-deno/)


Imports

Comparison with Node.js version

Permissions

Basic examples

Instantiate Airtable client

import { Airtable } from "https://deno.land/x/airtable/mod.ts";

const airtable = new Airtable({
  apiKey: "keyXXXXXXXXXXXXXX",
  baseId: "appXXXXXXXXXXXXXX",
  tableName: "Some table name",
});

Select record(s)

const results = await airtable.select();

Creating record(s)

const createOne = await airtable.create({
  Name: "Griko Nibras",
  Age: 25,
});

import { Field } from "https://deno.land/x/airtable/mod.ts";

type Fields = {
  Name: string;
  Age: number;
  Active?: Field.Checkbox;
};

const createMultiple = await airtable.create<Fields>(
  [
    { Name: "Foo", Age: 20 },
    { Name: "Bar", Age: 15 },
  ],
  { typecast: true }
);

Updating record(s)

const updateOne = await airtable.update<Fields>("recXXXXXXXXXXXXXX", {
  Name: "Adult boi",
  Age: 30,
});

const updateMultiple = await airtable.update<Fields>(
  [
    {
      id: "recXXXXXXXXXXXXXX",
      fields: { Name: "Adult boi", Age: 30 },
    },
    {
      id: "recXXXXXXXXXXXXXX",
      fields: { Name: "Yung boi", Age: 15 },
    },
  ],
  { typecast: true }
);

Delete record(s)

const deleteOne = await airtable.delete("recXXXXXXXXXXXXXX");

const deleteMultiple = await airtable.delete([
  "recXXXXXXXXXXXXXX",
  "recXXXXXXXXXXXXXX",
]);

Advanced examples

For advanced examples, view the examples.ts file.

Further reading

All options, parameters, errors, and responses are the same as on the Airtable API documentation.

Used by

Dependencies

License

MIT License Copyright (c) 2020 Griko Nibras