Skip to content

Table definitions

View as Markdown

@sapporta/server/table and Drizzle sqliteTable declarations.

  • sapportaTable({ drizzle, meta, validate }) joins one raw Drizzle table with Sapporta metadata and application validation as a TableDef.
  • Semantic factories are text, select, number, money, percentage, bool, date, and timestamp.
  • 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.PlainDate and Temporal.Instant, and database reads return those Temporal values.
  • Select and insert types come from $inferSelect and $inferInsert on the raw table.
  • Sapporta’s public table boundaries use SQL column names. Drizzle property names are translated immediately around database calls.
import {
sapportaTable,
text,
select,
date,
timestamp,
} from "@sapporta/server/table";