0
Get Record
One script reply has been approved by the moderators Verified
Created by nicolasdymkowy 662 days ago Viewed 3117 times
0
Submitted by henri186 Deno
Verified 338 days ago
1
import { Airtable } from "https://deno.land/x/airtable/mod.ts";
2

3
type Airtable = {
4
  apiKey: string;
5
};
6

7
type AirtableTable = {
8
  baseId: string;
9
  tableName: string;
10
};
11
export async function main(
12
  atCon: Airtable,
13
  atTable: AirtableTable,
14
  recordId?: string,
15
) {
16
  const airtable = new Airtable({ ...atCon, ...atTable });
17

18
  if (recordId) {
19
    const record = await airtable.find(recordId);
20
    return { result: record };
21
  } else {
22
    const records = await airtable.select().all();
23
    return { result: records };
24
  }
25
}
26

Other submissions