Types and modifiers, including ref with on delete and pii.
Fields
The types and the modifiers, on one invoice. customer, assignee, and parent are ref fields, and each says what happens on delete: restrict, nullify, or cascade. ssn is pii, so the platform treats it as personal data. net is computed from the two money fields. age_days carries its own check.
app billing "Billing" {}
entity Account {
name: text required
}
entity Invoice "Invoice" plural "Invoices" {
number: text required label "Number"
customer: ref Account on delete restrict
assignee: ref Account on delete nullify
parent: ref Invoice on delete cascade
issued_on: date
due_at: datetime
active: boolean
total: money USD
terms: longtext help "Shown on the printed invoice."
ssn: text pii hidden
attachment: file
status: enum draft, sent, paid
discount: money USD
net: computed number = total - discount
notes: json
age_days: number validate age_days >= 0 "Age cannot be negative."
}