Contribute to this page
Collection JSON
You can define a Collection as JSON and import it from the console (Database → Collections → Import). This page documents the exact shape.
- One collection = a JSON object.
- Many collections = a JSON array of those objects.
{ "name": "customers", // required, unique within the domain "description": "Customer master data", "fields": [ /* Field objects */ ], "indexDetails": [ /* Index objects, optional */ ]}Field object
Section titled “Field object”{ "name": "email", "type": "string", // see field types below "required": true, "onDelete": "ignore" // ignore | unset | cascade | reject}Field types: string, number, boolean, date, url, enum, json, editor,
file, relation, record.
recordis reserved for theidfield.enumrequires a non-emptyenumOptions: string[].relation(use for all foreign keys) requires:relatedCollectionID:{ "Table": "collections", "ID": "<target collection id>" }relationLinkType:"single"or"multiple"
onDelete behavior
Section titled “onDelete behavior”| Value | Effect when a referenced record is deleted |
|---|---|
ignore | do nothing |
unset | null the reference |
cascade | delete this record too |
reject | block the parent deletion |
Index object
Section titled “Index object”{ "fields": ["email"], "isUnique": true, "query": "" }- Use unique indexes for natural keys.
- Use non-unique indexes for fields you filter on (including foreign keys).
- Multiple
fieldscreate a composite index.
Standard fields
Section titled “Standard fields”Always include these three — the backend manages their values:
{ "name": "id", "type": "record", "required": true, "onDelete": "ignore" },{ "name": "created_dt", "type": "date", "required": false, "onDelete": "ignore" },{ "name": "updated_dt", "type": "date", "required": false, "onDelete": "ignore" }Complete example
Section titled “Complete example”A customers collection with a unique email index, plus an orders collection that
relates to it:
[ { "name": "customers", "description": "Customer master data", "fields": [ { "name": "id", "type": "record", "required": true, "onDelete": "ignore" }, { "name": "companyName", "type": "string", "required": true, "onDelete": "ignore" }, { "name": "email", "type": "string", "required": true, "onDelete": "ignore" }, { "name": "status", "type": "enum", "enumOptions": ["active", "inactive"], "required": false, "onDelete": "ignore" }, { "name": "created_dt", "type": "date", "required": false, "onDelete": "ignore" }, { "name": "updated_dt", "type": "date", "required": false, "onDelete": "ignore" } ], "indexDetails": [ { "fields": ["email"], "isUnique": true, "query": "" }, { "fields": ["status"], "isUnique": false, "query": "" } ] }, { "name": "orders", "description": "Customer orders", "fields": [ { "name": "id", "type": "record", "required": true, "onDelete": "ignore" }, { "name": "reference", "type": "string", "required": true, "onDelete": "ignore" }, { "name": "customerId", "type": "relation", "relatedCollectionID": { "Table": "collections", "ID": "customers_collection_id" }, "relationLinkType": "single", "required": true, "onDelete": "cascade" }, { "name": "total", "type": "number", "required": false, "onDelete": "ignore" } ] }]Tips for modeling
Section titled “Tips for modeling”- Create parent collections before children (so relation targets exist).
- Prefer
relationover storing raw id strings — relations enable expand and referentialonDeletebehavior. - Keep one canonical collection per entity; use relations rather than duplicating data.
See also Permission JSON and the Collections concept.