Data model

Field types

Field types drive API validation, physical constraints, defaults and dashboard editing.

TypeJSON inputGood fit
textStringNames, titles and descriptions
numberNumberScores, quantities and prices
booleanBooleanBinary states
datetimeUTC timestamp stringDeadlines and event times
jsonAny structured JSONVariable metadata
selectDeclared string choiceControlled workflow states
relationRecord ID stringReferences to records
emailEmail stringContact addresses
urlURL stringExternal links

Example values

{
  "title":"Investigate delivery retry",
  "priority":3,
  "resolved":false,
  "due_at":"2026-09-01T09:00:00Z",
  "status":"open",
  "owner_id":"rec_user_123",
  "metadata":{"source":"support"}
}

Common flags

required becomes a non-null constraint, unique becomes a uniqueness constraint, and defaults are validated against the field type before schema commit. Unknown fields and wrong JSON types produce indexed validation errors before SQLite is asked to write.

Relations

Relation values are validated record ID strings and can participate in rules. Target-collection and delete/update policy metadata are still required before Trestle can generate physical foreign-key constraints for relation fields.

Provider storage

Field types are a logical contract. SQLite stores them as STRICT text/real/integer with typed checks; the PostgreSQL provider uses native TEXT, DOUBLE PRECISION and BOOLEAN columns. Application validation and error envelopes are identical; only the physical mapping differs. See Physical schema.