Entity / Operators
Writing a computed value
Declared writes can compute new column values in SQL and preview them on the client using operators in compute:
import { Write } from 'foldkit-entity'
const joined = Expr.operator('acme.joined', {
input: [Schema.String, Schema.String],
output: Schema.String,
collation: 'operands',
})
const Retitle = Entity.input(
Product,
Schema.Struct({ id: Schema.String, suffix: Schema.String }),
{ suffix: Entity.unmapped },
)
const retitle = Write.update(Retitle, {
id: 'id',
compute: { label: ({ row, input }) => joined(row.label, input.suffix) },
})Write.apply(row, bound, { operators }) computes the optimistic row for guards, writers, and Remote previews while concurrent live updates layer cleanly underneath. Without expect: 'revision', computed writes require a ledger plus either a revision-pinned guard or a verified commutative/associative operator.
Filtering held client rows with matching
Because client and server share operator tables, matching(store, Query, input, { operators }) (foldkit-remote) returns { matched, skipped } over cached rows. matched preserves server sort order, while skipped lists rows missing required fields or containing text with NUL characters.
filtered(Data, model, list, Query, input) (foldkit-remote/filter) applies matching to a loaded list and reports complete: false whenever an operator is missing from the client's table so uncertain filters defer to the server.