Table definition with CRUD operations
columns: readonly string[]
Physical DB columns declared for this table, in schema order.
deleteById: (id: InValue) => Promise<void>
Delete a row by primary key
Find a row by primary key, or null when it does not exist.
findByIdPrimary: (id: InValue) => Promise<Row | null>
Find a row by primary key, pinned to the primary (read-your-writes). Use when reading a row back immediately after committing its own write: a plain findById runs in "read" mode, which Turso may serve from a replica that lags behind the just-committed write and so miss the row (returning null). This reads on the primary, which always reflects the write.
Optional, like insertStatement/updateStatement: only the transactional CRUD-side-effect write path reads a row back this way, so a façade table that never takes that path may omit it.
Find rows in input order, retaining nulls for missing primary keys.
inputKeyMap: Record<string, string>
insertStatement: (input: Input,condition?: SqlStatement,) => Promise<SqlStatement>
Build the INSERT statement without executing it (for transactional callers). Optional: only resources with a CRUD side effect need it; façade tables omit it.
name: string
primaryKey: keyof Row & string
rowToInput: (row: Row,exclude?: readonly string[],) => Partial<Input>
Build an Input object from an existing Row by copying the input-eligible
columns and translating keys through inputKeyMap. Lets callers spread
a row into a new insert without restating every field. Columns named in
exclude are skipped — useful for auto-stamped fields like created.
toDbValues: (input: Input | Partial<Input>) => Promise<Record<string, InValue>>
Transform input to DB values (apply write transforms and defaults)
Update a row by primary key, returns updated row or null if not found
updateStatement: () => Promise<SqlStatement>
Build the UPDATE statement without executing it (input must provide ≥1 column). Optional: see insertStatement.