2023-10-31 01:48:29 +02:00
|
|
|
---
|
|
|
|
|
gitea: none
|
|
|
|
|
include_toc: true
|
|
|
|
|
---
|
2023-10-30 22:51:54 +02:00
|
|
|
|
2023-10-30 22:49:27 +02:00
|
|
|
# Schemas
|
|
|
|
|
|
2026-04-20 21:13:31 +03:00
|
|
|
Schemas define both the shape of your data and how the admin UI behaves.
|
2023-10-30 22:49:27 +02:00
|
|
|
|
2026-04-20 21:13:31 +03:00
|
|
|
There are 2 types of schemas:
|
2023-10-30 22:49:27 +02:00
|
|
|
|
2026-04-20 21:13:31 +03:00
|
|
|
- **collection** — Regular data records
|
|
|
|
|
- **files** — Images and file uploads
|
2023-10-30 22:49:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
## Collection Reference
|
|
|
|
|
|
2026-04-20 21:13:31 +03:00
|
|
|
| Field | Required | Description |
|
|
|
|
|
|---|---|---|
|
|
|
|
|
| `name` | yes | Unique ID. Use camelCase plural e.g. `blogPosts` |
|
|
|
|
|
| `label` | yes | Friendly display name |
|
|
|
|
|
| `type` | yes | Must be `"collection"` |
|
|
|
|
|
| `fields` | yes | Array of field definitions. See [Fields](Fields.md) |
|
|
|
|
|
| `visible` | no | Field IDs to show in the content browser list |
|
|
|
|
|
| `groups` | no | Group IDs to split fields into tabs |
|
|
|
|
|
| `isEntry` | no | Show in sidebar. Default: `false` |
|
|
|
|
|
| `sortBy` | no | Default sort in browser. Prefix with `-` for descending e.g. `-_sys.updatedAt` |
|
|
|
|
|
| `cardTitle` | no | Mustache template for the record preview title e.g. `{{name}} - {{slug}}` |
|
|
|
|
|
| `cardImage` | no | Field name to use as the preview image |
|
|
|
|
|
| `revisions` | no | Number of revisions to keep per record. Default: `0` (disabled) |
|
|
|
|
|
| `read` | no | Roles with read access. Empty means all roles can read |
|
|
|
|
|
| `write` | no | Roles with write access. Empty means all roles can write |
|
2023-10-30 22:49:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
## Files Reference
|
|
|
|
|
|
2026-04-20 21:13:31 +03:00
|
|
|
| Field | Required | Description |
|
|
|
|
|
|---|---|---|
|
|
|
|
|
| `name` | yes | Unique ID. Use camelCase plural e.g. `heroImages` |
|
|
|
|
|
| `label` | yes | Friendly display name |
|
|
|
|
|
| `type` | yes | Must be `"files"` |
|
|
|
|
|
| `fields` | yes | Array of field definitions. See [Fields](Fields.md) |
|
|
|
|
|
| `disk` | no | Laravel disk name. Default: `"lucent"` |
|
|
|
|
|
| `path` | no | Subdirectory for uploads. Default: schema name |
|
|
|
|
|
| `groups` | no | Group IDs to split fields into tabs |
|
|
|
|
|
| `isEntry` | no | Show in sidebar. Default: `false` |
|
|
|
|
|
| `sortBy` | no | Default sort in browser |
|
|
|
|
|
| `cardTitle` | no | Mustache template for the record preview title |
|
|
|
|
|
| `cardImage` | no | Field name to use as the preview image |
|
|
|
|
|
| `revisions` | no | Number of revisions to keep per record |
|
|
|
|
|
| `read` | no | Roles with read access |
|
|
|
|
|
| `write` | no | Roles with write access |
|
2023-10-30 22:49:27 +02:00
|
|
|
|
|
|
|
|
|
2026-04-20 21:13:31 +03:00
|
|
|
## System Fields
|
|
|
|
|
|
|
|
|
|
Every record automatically has these read-only system fields available in queries:
|
|
|
|
|
|
|
|
|
|
| Field | Description |
|
|
|
|
|
|---|---|
|
|
|
|
|
| `_sys.createdAt` | ISO 8601 creation timestamp |
|
|
|
|
|
| `_sys.updatedAt` | ISO 8601 last update timestamp |
|
|
|
|
|
| `_sys.createdBy` | User ID who created the record |
|
|
|
|
|
| `_sys.updatedBy` | User ID who last updated the record |
|
|
|
|
|
| `_sys.version` | Revision version number |
|
|
|
|
|
| `status` | `draft` or `published` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Example
|
2023-10-30 22:49:27 +02:00
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
2026-04-20 21:13:31 +03:00
|
|
|
"schemas": [
|
|
|
|
|
{
|
|
|
|
|
"label": "Blog Posts",
|
|
|
|
|
"name": "blogPosts",
|
|
|
|
|
"isEntry": true,
|
|
|
|
|
"type": "collection",
|
|
|
|
|
"visible": [
|
|
|
|
|
"title",
|
|
|
|
|
"slug",
|
|
|
|
|
"_sys.updatedAt",
|
|
|
|
|
"status"
|
|
|
|
|
],
|
|
|
|
|
"groups": [
|
|
|
|
|
"Content",
|
|
|
|
|
"SEO"
|
|
|
|
|
],
|
|
|
|
|
"sortBy": "-_sys.createdAt",
|
|
|
|
|
"cardTitle": "{{title}}",
|
|
|
|
|
"cardImage": "cover",
|
|
|
|
|
"revisions": 15,
|
|
|
|
|
"read": [
|
|
|
|
|
"admin",
|
|
|
|
|
"editors",
|
|
|
|
|
"reviewers"
|
|
|
|
|
],
|
|
|
|
|
"write": [
|
|
|
|
|
"admin",
|
|
|
|
|
"editors"
|
|
|
|
|
],
|
|
|
|
|
"fields": []
|
|
|
|
|
}
|
2023-10-30 22:49:27 +02:00
|
|
|
],
|
2026-04-20 21:13:31 +03:00
|
|
|
"roles": ["admin", "editors", "reviewers"]
|
2023-10-30 22:49:27 +02:00
|
|
|
}
|
2026-04-20 21:13:31 +03:00
|
|
|
```
|