Skip to main content
Every app gets a typed database client, generated from the workspace schema. Import it from zitejs/db:
The client is used inside backend workflows — the frontend never talks to the database directly. Each table is a property on zite, addressed by its SDK name (PascalCase), with fully-typed record types. Read the generated .zite/db.ts to see the exact names and types.

Methods

Filters and sorting

Filters are objects keyed by field SDK name. A bare value means equality; an object applies an operator:
There is no eq or neq here — equality is the bare-value shorthand. The row filters in zite.permissions.json are a separate system and do have eq and neq.
Sort is an array: sort: [{ field: 'createdAt', direction: 'desc' }]. Use fields: ['subject', 'status'] to fetch only the columns you need.
findAll returns at most 2,000 records (hasMore tells you there are more). For counts, sums, group-bys, and joins, use zite.sql() — aggregating in JavaScript over a capped result set gives wrong numbers on large tables.

Read-only SQL

zite.sql() runs a single read-only SELECT against the workspace database using human-readable SDK names:
Always use SDK names, never display labels. A wrong name is a runtime error, not a type error: Postgres lowercases unquoted names, which is why everything but the system columns must be double-quoted. The .zite/db.ts header lists the link tables for your workspace.
SELECT only. Pass runtime values through params ($1, $2, …) — never string-interpolate them into the query. Soft-deleted rows are excluded automatically.
Results are capped at 2,000 rows; truncated is true when the cap is hit.

Also on the client

The generated zite object also exposes zite.notifications (see Notifications) and zite.meta.listUsers() for the workspace’s users.