Skip to content

Latest commit

 

History

History
78 lines (57 loc) · 1.97 KB

File metadata and controls

78 lines (57 loc) · 1.97 KB

model

Declare a database table with typed fields and constraints.

Kind Keyword
Since 0.1.0
Repeatable yes

Syntax

model <name>

Arguments

Name Type Required
name identifier yes

Description

A model declares a persistent entity backed by a SQL table. The runtime auto-migrates the schema: adding fields, indexes, and unique constraints triggers ALTER TABLE on next start. Field declarations use name: <type> [constraint...]. Built-in types include text, email, int, float, bool, timestamp, date, uuid, password, image, file, json, reference <model>, option [a, b, c], tags, and others.

Children

Examples

User model with constraints

model user
  email: email required unique
  name: text required
  role: option [admin, editor, viewer] default "viewer"
  age: int min 18 max 120
  created_at: timestamp auto

Multi-tenant model

model invoice
  tenant: account
  amount: decimal required
  status: option [draft, sent, paid] default "draft"
  index (tenant, status)

See also

Provenance

Implementation touched after spec. Source code changed on 2026-05-20, but this entity's spec was last edited on 2026-05-08. The description may be out of date.

Spec last touched 5da8498 (2026-05-08)
Source last touched af278bb (2026-05-20)
Source files internal/parser/parser.go