interface Table

Table definition with CRUD operations

Type Parameters

Row
Input

Properties

deleteById: (id: InValue) => Promise<void>

Delete a row by primary key

findAll: () => Promise<Row[]>

Find all rows

findById: (id: InValue) => Promise<Row | null>

Find a row by primary key

fromDb: (row: Row) => Promise<Row>

Transform a row from DB (apply read transforms)

inputKeyMap: Record<string, string>
insert: (input: Input) => Promise<Row>

Insert a new row, returns the created row

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: (
id: InValue,
input: Partial<Input>
) => Promise<Row | null>

Update a row by primary key, returns updated row or null if not found