Unique rules
unique: true in a field's block means no two records may hold the same
value in that field. A rule over several fields goes in the entity's
unique: { } section, with a name and its fields as a list:
type ProjectName = Text { max_length: 80}entity User { id: Uuid email: Email { unique: true // one user per address }}entity Project { id: Uuid owner_id: User.id { on_delete: OnDelete.cascade } name: ProjectName unique: { name_per_owner: [owner_id, name] }}
Here one user may own only one project of a given name. A rule's fields must exist, be different fields, and be required, so every engine agrees on what a duplicate is. A write that breaks the rule refers to it by its name when it maps the conflict to a failure (Conflicts).
On a tenant's records, a rule holds within each tenant: its key holds the tenancy reference too (A unique rule holds within its tenant).
Markdown for agents: /docs/unique-rules.md.Built from Jadpo main at a707efb.