Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Griko Nibras committed May 21, 2020
0 parents commit a9c4a45
Show file tree
Hide file tree
Showing 14 changed files with 824 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
AIRTABLE_API_KEY=
AIRTABLE_ENDPOINT_URL=https://api.airtable.com/v0
AIRTABLE_BASE_ID=
AIRTABLE_TABLE_NAME=
11 changes: 11 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
issuehunt: grikomsn
ko_fi: grikomsn
liberapay: grikomsn
custom: ['https://karyakarsa.com/grikomsn', 'https://saweria.co/grikomsn', 'https://trakteer.id/grikomsn']

community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
open_collective: # Replace with a single Open Collective username
otechie: # Replace with a single Otechie username
patreon: # Replace with a single Patreon username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.log
.DS_Store
.env

!.env.example
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deno.enable": true
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License Copyright (c) 2020 Griko Nibras

Permission is hereby granted, free
of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the
following conditions:

The above copyright notice and this permission notice
(including the next paragraph) shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
138 changes: 138 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<!-- markdownlint-disable MD033 MD036 MD041 -->

<div align='center'>

![airtable-deno](./header.png)

![release](https://badgen.net/github/release/grikomsn/airtable-deno/)

</div>

---

- [Imports](#imports)
- [Comparison with Node.js version](#comparison-with-nodejs-version)
- [Permissions](#permissions)
- [Basic examples](#basic-examples)
- [Advanced examples](#advanced-examples)
- [Further reading](#further-reading)
- [Dependencies](#dependencies)
- [License](#license)

---

## Imports

- <https://denopkg.com/grikomsn/airtable-deno/mod.ts>
- <https://griko.dev/airtable-deno.ts>

## Comparison with [Node.js version](https://github.com/Airtable/airtable.js)

- Using built-in Deno `fetch` and [only one dependency](#dependencies)
- First-class support for generic field types with extra field types (`Collaborators`, `MultipleSelect<T>`, etc.)
- Single object instance (`new Airtable()` instead of `new Airtable().base()().select()...`)

## Permissions

- **`--allow-net`**

Network access for `fetch`ing and requesting datas to Airtable API endpoints.

- **`--allow-env` (optional)**

Configuring Airtable options via environment variables instead of passing values (see [advanced examples](#advanced-examples)).

## Basic examples

**Instantiate Airtable client**

```ts
import { Airtable } from "https://griko.dev/airtable-deno.ts";

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

**Select record(s)**

```ts
const results = await airtable.select();
```

**Creating record(s)**

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

import { Field } from "https://griko.dev/airtable-deno.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)**

```ts
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)**

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

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

## Advanced examples

For advanced examples, view the [`examples.ts`](./examples.ts) file.

## Further reading

All options, parameters, errors, and responses are the same as on the [Airtable API documentation](https://airtable.com/api).

## Dependencies

- `querystring`: <https://deno.land/std@0.52.0/node/querystring.ts>

## License

MIT License Copyright (c) 2020 [Griko Nibras](https://github.com/grikomsn)
Loading

0 comments on commit a9c4a45

Please sign in to comment.