The schema is a JSON object sent to PUT /p/{id}/v1/schema:
{
"tables": {
"users": {
"columns": {
"display_name": "string",
"avatar": "file",
"role": { "type": "enum", "values": ["user", "admin"], "default": "user" }
},
"auth_table": true // auto-creates email + password_hash
},
"posts": {
"columns": {
"user_id": "ref users required",
"title": "string required",
"body": "text",
"published": "bool default false"
},
"access": { "read": "public", "create": "authenticated", "update": "owner", "delete": "owner" },
"owner_field": "user_id"
}
}
}
Every table automatically gets these — never define them:
id — UUID v4, primary keycreated_at — ISO 8601 timestamp, set on insertupdated_at — ISO 8601 timestamp, updated on every change| Option | Type | Description |
|---|---|---|
auth_table | boolean | Enable email/password auth. Auto-creates email (string, required, unique) and hidden password_hash. |
verify_email | boolean | Require email verification for auth users. |
access | object | Per-operation access rules: read, create, update, delete. |
owner_field | string | Required when access is "owner". Must be a ref column pointing to auth table. MoonDB compares it with user id from JWT — users only see/edit their own rows. Auto-filled on INSERT. Use "id" on auth_table itself. |
unique | string[][] | Compound unique: [["user_id","slug"]]. |