1.0.21 • Published 9 months ago

@glideapps/tables v1.0.21

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

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

// List all apps
const apps = await glide.getApps();

// Create a reference to an app using its ID
const myApp = glide.app("bAFxpGXU1bHiBgUMcDgn");

// Or get by name
const myApp = await glide.getAppNamed("Employee Directory");

// Get all tables
const tables = await myApp.getTables();

// Get a table by name
const users = await myApp.getTableNamed("Users");

// Get PWA manifest (name, description, icons)
const manifest = await myApp.getManifest();

Tables

const inventory = glide.table({
  // App and table IDs
  app: "bAF...Dgn",
  table: "native-table-tei...",

  columns: {
    // Column names map to their types.
    // You can use this shorthand with internal names only.
    Item: "string",
    Price: "number",

    // When you want to work with display names, you'll need
    // to alias them like this.
    Assignee: { type: "string", name: "7E42F8B3-9988-436E-84D2-5B3B0B22B21F" },
  },
});

// Get all rows (Business+)
const rows = await inventory.get();

// Query rows – Big Tables only (Business+)
const rows = await inventory.get(q => q.where("Price", ">", 100));

// Add a row
const rowID = await inventory.add({
  Item: "Test Item",
  Price: 100,
  Assignee: "David",
});

// Add many rows
await inventory.add([jacket, shirt, shoes]);

// Change a row
await inventory.update(rowID, {
  Price: 200,

  // Use null to clear columns
  Assignee: null,
});

// Delete a row
await inventory.delete(rowID);

// Clear all rows (Business+)
await inventory.clear();

Schema & Types

// Get table schema info (columns with names and types)
const schema = await inventory.getSchema();

// Name the row type (optional)
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",
  /* ... */
});
1.0.21

9 months ago

1.0.20

9 months ago

1.0.19

9 months ago

1.0.18

9 months ago

1.0.17

9 months ago

1.0.16

9 months ago

1.0.15

9 months ago

1.0.14

9 months ago

1.0.13

9 months ago

1.0.11

9 months ago

1.0.12

9 months ago

1.0.9

10 months ago

1.0.10

10 months ago

1.0.8

10 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago

1.0.7

12 months ago

1.0.6

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

0.0.15

1 year ago

0.0.16

1 year ago

0.0.17

1 year ago

0.0.18

1 year ago

0.0.12

1 year ago

0.0.13

1 year ago

0.0.14

1 year ago

0.1.0

12 months ago

0.2.1

12 months ago

0.1.2

12 months ago

0.2.0

12 months ago

0.1.1

12 months ago

0.1.8

12 months ago

0.1.7

12 months ago

0.2.3

12 months ago

0.1.4

12 months ago

0.2.2

12 months ago

0.1.3

12 months ago

0.2.5

12 months ago

0.1.6

12 months ago

0.2.4

12 months ago

0.1.5

12 months ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago