-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Griko Nibras
committed
May 21, 2020
0 parents
commit a9c4a45
Showing
14 changed files
with
824 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.log | ||
.DS_Store | ||
.env | ||
|
||
!.env.example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"deno.enable": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.