Skip to main content
These examples describe the current Bijection CLI and SDK source. Use builds from the same repository revision for these APIs. The public CLI and npm SDK are released independently and may lag this reference.
This page builds the smallest useful pipeline: per-customer order totals, computed by Bijection from the orders table, kept current as orders change, and read with an ordinary query and useQuery. Nothing runs on your own infrastructure; customer compute comes later.

1. Share the row validator

Declare the row once. The table and the computation’s input both use it.
bijection/rows.ts

2. Declare the computation

A table computation declares args, its inputs (row validators), its returns and a handler. groupBy runs the handler once per customer: ctx.inputs.orders holds that customer’s rows and ctx.groupKey their key. The handler reads only these captured rows; there is no ctx.db. When a customer’s orders all disappear, the handler runs with an empty input and returning no row removes that customer’s total. maintain keeps the latest result current: refresh when inputs change, at most once a second, and replace the readable result when a new one is accepted.
bijection/totals.ts
The orders input reads the orders table, because they share a name. To read another table, add bindExecution(nativeExecution(totals, { inputs })) from @bijection/pipelines.

3. Publish the result as a table

defineSyncedTable turns the maintained output into a read-only table keyed by the output’s key. Mutations cannot write it; each accepted result replaces its rows in one transaction.
bijection/schema.ts

4. Say who may run it

Declare the application’s computation policy once. It decides who may start, inspect and maintain computations, including the maintenance program itself. Reading orders and customer_totals still follows their own access.
bijection/application.ts

5. Read it in React

The list query in totals.ts reads customer_totals like any table, and the component subscribes to it. Subscribers see each new result as soon as it is selected.
src/Totals.tsx

Next steps

  • Published tables covers keys, indexes, freshness, retention and explicit selection.
  • Pipelines covers partitioning, folds over large inputs, checks before acceptance and temporal computations.
  • Customer compute runs Python, Spark or dbt on your own infrastructure under the same contract.