docs updated
This commit is contained in:
+83
-60
@@ -5,80 +5,103 @@ include_toc: true
|
||||
|
||||
# Schemas
|
||||
|
||||
Schemas define both the shape of your data and how the UI on the admin will behave.
|
||||
Schemas define both the shape of your data and how the admin UI behaves.
|
||||
|
||||
There are 3 types of schemas
|
||||
There are 2 types of schemas:
|
||||
|
||||
- Collections: Normal data
|
||||
- Files: Images and files
|
||||
- Block: Used in the block editor
|
||||
- **collection** — Regular data records
|
||||
- **files** — Images and file uploads
|
||||
|
||||
|
||||
## Collection Reference
|
||||
|
||||
- **name**: The ID of the collection. Camelcase and plural is the recommended format ex. blogPosts
|
||||
- **label**: The friendly name of the schema
|
||||
- **type**: The type of the collection. Should be "collection"
|
||||
- **visible**: An array of field id to show on the content browser _optional_
|
||||
- **groups**: A list if group ids to separate your field in different tabs _optional_
|
||||
- **fields**: The list of your fields. Look the field reference for more
|
||||
- **isEntry**: If this schema is important, it will show be visible on the main the sidebar. Default: false _optional_
|
||||
- **sortBy**: The default sorting in the content browser _optional_
|
||||
- **cardTitle**: Mustache code to customize the preview field _optional_
|
||||
- **cardImage**: Field name of image you want to use as a preview image _optional_
|
||||
- **revisions**: How many revisions are going to be kept for each record _optional_
|
||||
- **read**: Array of user groups that have read permissions _optional_
|
||||
- **write**: Array of user groups that have write permissions _optional_
|
||||
| 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 |
|
||||
|
||||
|
||||
## Files Reference
|
||||
|
||||
- **name**: The ID of the collection. Camelcase and plural is the recommended format ex. blogPosts
|
||||
- **label**: The friendly name of the schema
|
||||
- **type**: The type of the collection. Should be "files"
|
||||
- **path**: The relative directory that these files will be stored.
|
||||
- **groups**: A list if group ids to separate your field in different tabs _optional_
|
||||
- **fields**: The list of your fields. Look the field reference for more
|
||||
- **isEntry**: If this schema is important, it will show be visible on the main the sidebar _optional_
|
||||
- **sortBy**: The default sorting in the content browser _optional_
|
||||
- **cardTitle**: Mustache code to customize the preview field _optional_
|
||||
- **revisions**: How many revisions are going to be kept for each record _optional_
|
||||
- **read**: Array of user groups that have read permissions _optional_
|
||||
- **write**: Array of user groups that have write permissions _optional_
|
||||
| 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 |
|
||||
|
||||
|
||||
A full Collection example without the fields:
|
||||
## 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
|
||||
|
||||
```json
|
||||
{
|
||||
"label": "Departments",
|
||||
"name": "departments",
|
||||
"isEntry": true,
|
||||
"type": "collection",
|
||||
"visible": [
|
||||
"slug",
|
||||
"cover",
|
||||
"_sys.updatedAt",
|
||||
"status"
|
||||
"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": []
|
||||
}
|
||||
],
|
||||
"groups": [
|
||||
"Extra Info",
|
||||
"Metadata",
|
||||
"SEO"
|
||||
],
|
||||
"sortBy": "-_sys.createdAt",
|
||||
"schemaTitle": "{{name}} {{slug}}",
|
||||
"schemaImage": "cover",
|
||||
"revisions": 15,
|
||||
"read": [
|
||||
"admin",
|
||||
"editors",
|
||||
"reviewers"
|
||||
],
|
||||
"write": [
|
||||
"admin",
|
||||
"editors"
|
||||
],
|
||||
"fields": []
|
||||
"roles": ["admin", "editors", "reviewers"]
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user