1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// 1. Start by importing the Glide helper library.
//
// Soon, this functionality will be part of the official
// @glideapps/tables npm package.
import * as Glide from "https://esm.town/v/dvdsgl/glide?v=661";
// 2. Add an environment variable named "glide" with your Glide API
// token.
//
// You can set this up here:
// https://www.val.town/settings/environment-variables
// 3. Identify the table where you want to import data:
const table = "replace-me-abc123-xyz456";
// 4. Implement row fetching using an API or a library:
//
// For example, you could call an API in a loop, using yield for each
// batch of rows to import.
async function* getRows() {
// Yield rows to import them:
yield { name: "David", favoriteTool: "Glide" };
// You can also yield arrays of rows:
yield [
{ name: "Mark", favoriteTool: "Glide" },
{ name: "Jason", favoriteTool: "Glide" },
];
}
// 5. Run the import.
//
// Warning: This API will completely replace the contents and columns
// of the target table.
await Glide.importTable({ table, getRows });