Glide Tables Client
Setup
Install package:
npm install @glideapps/tables
Import it:
import * as glide from "@glideapps/tables";
Generate a client:
# Interactive:
npx @glideapps/tables
# One-shot
GLIDE_TOKEN=... npx @glideapps/tables [APP_ID] [FILE_NAME]
Authorization
Set GLIDE_TOKEN
environment variable or pass the token as props.
Using a particular client? Add GLIDE_CLIENT_ID
environment variable or pass the value as props.
Apps
const apps = await glide.getApps();
const myApp = glide.app("bAFxpGXU1bHiBgUMcDgn");
const myApp = await glide.getAppNamed("Employee Directory");
const tables = await myApp.getTables();
const users = await myApp.getTableNamed("Users");
const manifest = await myApp.getManifest();
Tables
const inventory = glide.table({
app: "bAF...Dgn",
table: "native-table-tei...",
columns: {
Item: "string",
Price: "number",
Assignee: { type: "string", name: "7E42F8B3-9988-436E-84D2-5B3B0B22B21F" },
},
});
const rows = await inventory.get();
const rows = await inventory.get(q => q.where("Price", ">", 100));
const rowID = await inventory.add({
Item: "Test Item",
Price: 100,
Assignee: "David",
});
await inventory.add([jacket, shirt, shoes]);
await inventory.update(rowID, {
Price: 200,
Assignee: null,
});
await inventory.delete(rowID);
await inventory.clear();
Schema & Types
const schema = await inventory.getSchema();
type InventoryItem = glide.RowOf<typeof inventory>;
Queries
Big Tables can be queried using SQL.
const first10 = await items.get(q => q.limit(10));
const cheapest = await items.get(q => q.orderBy("Price"));
const expensiveInLA = await items.get(
q => q
.orderBy("Price", "DESC")
.where("Quantity", ">", 10_000)
.and("Port", "=", "Los Angeles")
.limit(100);
);
Development
nvm i
npm run build
npm t
Advanced Options
You can specify an alternate Glide environment (for internal testing by Glide).
const staging = new Glide({
endpoint: "https://staging.heyglide.com/api/container",
});
Or with the package:
import * as glide from "@glideapps/tables";
const staging = glide.withConfig({
endpoint: "https://staging.heyglide.com/api/container",
});