entitydefines persisted database records.schemadefines reusable structured values that are not stored as their own table.
Entities
An entity becomes a database-backed model. Fields are declared underfields, and relations are declared separately so both sides of a relationship are visible.
Field Types
Persisted fields support these SLang types:| Type | Use |
|---|---|
TEXT | General strings. |
EMAIL | Email-shaped strings; commonly used as identity fields. |
PHONE_NUMBER | Phone numbers. |
ADDRESS | Postal address text. |
NUMBER | Integer or decimal numbers. |
CURRENCY_AMOUNT | Currency amount strings. |
BOOLEAN | true or false. |
DATE | Calendar dates. |
TIME | Time values. |
DATE_TIME | Timestamps. |
URL | Web links. |
FILE | Uploaded or stored document/blob values. |
ENUM("a", "b") | Inline string enum. |
SomeEnum | Named enum declared with enum. |
? to make a field optional. Use := for static defaults.
Field Metadata
Common field metadata includes:description "..."for generated docs and editor context.minLength 1for minimum text length.computed <expression>for computed fields.
null.
Schemas
Schemas use the samefields shape as entities, but they are structural types, not persisted database tables. Schemas can reference other schemas, including arrays of schemas.
Relations
Relations connect entities and add relation fields to both sides. The general shape is:relation Left[leftField] cardinality --- cardinality Right[rightField]
For example, relation User[tasks] 1 --- 0..* Task[owner] means:
user.tasksresolves to a list of tasks.task.ownerresolves to the owning user.- Creating or updating a
Taskcan assignowner := someUserorowner := @subjectwhen the field points to the subject entity.