Skip to main content
A table is declared with its fields and options, and placed in the app tree. Its path in the tree is its name: the table orders in the module mounted at shop is shop.orders.
bijection/shop.ts

Options

Durations are Temporal.Duration values or duration literals such as { days: 30 }. See History and lifetime.

Keys

Without key, the host mints each fact’s key. ctx.insert(table, fact) returns it, and a read fact carries it in its id field. Store it in another fact with t.key(table).
With key, the named fields identify the fact. A one-field key is passed alone, and a longer key as an object. The fact a write supplies leaves the key fields out, because the point already holds them.

Labels

A table’s label is the audience of its facts. A frame reads a labelled fact only when its roles clear the label, and a function writes into it only when its under flows to the label. A field declared label.seal(type) is sealed above the fact’s label: a read returns it as a Sealed<V>, and ctx.open shows the value within the frame’s clearance. A label family puts each fact in the frame’s member: see Family tables. Label rules are in Read rules and Write rules. A labelled, erasable or expiring table is protected: its indexes keep tokens of their fields at the store, so a selection that does not fix every field of an index is read with ctx.list(selection.atMost(n)).

Constraints are reads

unique, a capacity, a pin quota and a t.shared field are constraints checked where the write lands. An erasure owner reference (erasable: { subject: "<field>" }) is also a constraint. A write of an owned image checks it at the owner’s fixed place, even if the image lands at another place. Each check must read at or below the function’s under, including in a blind insert, put or retract. A table’s own lifetime starts at the write’s commit. A referenced owner’s lifetime bounds the commit of an owned image.
bijection check reports such a write at its call site, and the host refuses it with ConstraintAboveWriter. Use a function whose under clears the place where the constraint is checked. An erased owner refuses Erased/OwnerClosed. A past-due owner refuses Expired/OwnerExpired, including before the lifetime sweep records its closure. Deploy also refuses a constraint on a table the host itself writes across labels, such as a marks table. Here the post and comment both sit at finance. The mutation runs under finance so it can check whether the post’s erasure unit is still open.

Declared covers (across)

A fact lives once, at its own label’s partition. When a wide frame reads across a family stem (under: tenant.all) or a disjunctive share (label.principals), declare across on the table or on the specific index, search field, vector field, total or .changes feed it reads:
  • Table-level across covers every path (including by-id points), totals and .changes: across: tenant.all serves under: tenant.all; across: label.principals serves each member of a disjunctive share at its own place.
  • Path-level across covers only that path (index: [{ fields: ["state", "placed"], across: tenant.all }], t.text({ across: tenant.all }), t.vector(1536, { across: tenant.all }), total: [{ group: ["state"], across: tenant.all }], or changesAcross). On a strict update, only changed covered values write to the cover.
  • bijection.lock prints each member-placed table’s witness count and declared covers per fact (for example, orders: 1 cover (tenant.all)).
  • Keyed and by-id points. A minted id such as orders(id) identifies one fact across the admitted roots. A point by a Place-local key such as users.of(member)({ email }) needs one Place. A selection under the family stem can return every matching email through a declared read cover. To serve a shared handle point, declare a family-stem unique scope and a separate read cover for the handle index. Shared claims

Series and timelines

series and timeline declare tables with valid time. Both require key.
See Series and timelines.

Acceptance time

t.accepted() is a Temporal.Instant the store fills with the commit’s own time when it accepts the write. A write omits it, a table declares at most one, and it is never a key, sealed or in a unique set (the store fills it after every unique claim is planned, so nothing could hold it unique). An index on it sorts every later commit’s facts after every fact any frame has seen, so a full page read oldest first never conflicts with later arrivals (Reading a queue).

Fact types

FactOf<typeof orders> is a read fact, and KeyOf<typeof orders> its key. As value types, t.fact(orders) and t.key(orders) declare a function’s arguments or return value. t.key(() => orders) names a table declared later in the module, and t.key.self the key of the table the field belongs to.

Writers and synced tables

Synced tables (from connector apps and @bijectionhq/library-replicas) are ordinary keyed tables declared with writers: () => [landing] and exposed to callers through table.readOnly(...). writers compiles into a host write guard on act.write(table) that permits only the named mutations or subtrees to write from application code, while table.readOnly(...) rejects writes at compile time. Direct operator writes to these tables refuse Forbidden. See Writers.

Where to declare tables

Declare a table in the module that owns its functions, and place the module in the app tree. A library that owns tables is a function returning a subtree with its tables and functions; each call makes a fresh set at the path where the installer places it. See Mountable apps.