Table definitions
View as MarkdownIdentity
Section titled “Identity”@sapporta/server/table and Drizzle sqliteTable declarations.
Contract
Section titled “Contract”sapportaTable({ drizzle, meta, validate })joins one raw Drizzle table with Sapporta metadata and application validation as aTableDef.- Semantic factories are
text,select,number,money,percentage,bool,date, andtimestamp. select(name, options)stores its allowed string values on the Drizzle text column. The same tuple drives TypeScript inference, structural validation, OpenAPI, metadata, forms, grids, and filters.- Primary and foreign keys use Drizzle integer columns.
- Generated API writes use canonical date and timestamp strings. Direct Drizzle
code uses
Temporal.PlainDateandTemporal.Instant, and database reads return those Temporal values. - Select and insert types come from
$inferSelectand$inferInserton the raw table. - Sapporta’s public table boundaries use SQL column names. Drizzle property names are translated immediately around database calls.
Minimal lookup
Section titled “Minimal lookup”import { sapportaTable, text, select, date, timestamp,} from "@sapporta/server/table";