Sierra guide / Resources
Seeded from the schema
At build time Sierra reads db/schema.lite and registers every model before any route runs, so a resource file names a model and nothing else. make() returns a blank record with the schema's defaults, and fields, relations and gate come from the same place.
const blank = leads.make({ status: 'new' }) // defaults from db/schema.lite
if (blank.status !== 'new' || blank.value !== 0) throw new Error(`unexpected defaults: ${JSON.stringify(blank)}`)
What else it can do
- The schema is found at
db/schema.lite, then../db/schema.lite, thenschema.lite, relative to the Vite root schema: 'path/to/x.lite'insierra.config.jspoints at another file, andschema: falseturns seeding off- A plural service name finds its model (
leadsisLead,companiesisCompany), andmodel: 'Child'names it where the plural is irregular resource.context.modelreports the model as the.litefile declares it- Enums,
typedeclarations andFileRefare registered as definitions, not resources
In depth: Sierra README § Schema seeding, § Naming: service ⇄ model