Content Type DSL
migration.createContentType('dog')
|
Create a new content type with given id |
|
Set content type display name |
.description('A type of animal')
|
Set content type description |
.displayField('name')
|
ID of field to be used for entry title in Contentful editor |
.createField('owner', options?)
|
Create a new field on the content type |
.editField('owner', options?)
|
Edit the given field |
.moveField('owner').toTheTop()
|
Move the field up or down in Contentful editor |
.deleteField('owner')
|
Delete the field from the content type |
.changeFieldId('woofs', 'numWoofs')
|
Change the JSON fields[i].id
|
Fields DSL
dog.createField('owner')
|
Create a field |
|
Set display name in Contentful editor |
|
Set field type - see below |
|
Only when type is 'Array' - define type of items in array |
|
Only when type is 'Link' - define type to link to |
.validations([ { ... } ])
|
Set validations on a field |
|
Set field as required |
|
Set field as having translations |
|
Set field to be not editable |
|
Set field to not be sent over CDN |
|
Deletes the field |
|
|
Field Types
Symbol |
Short text max 256 chars |
Text |
Long text - markdown - max 50k chars |
Integer |
signed integer -253 to 253 |
Number |
floating point number -253 to 253 |
Date |
ISO 8601 date and time string. Can come back with no TZ info, ex. "2015-11-06T09:45:27"
|
Location |
lat-lon pair ex. {"lat": 52.5208, "lon": 13.4049}
|
Boolean |
|
Link |
Link to another entry or asset, ex. {"sys": {"type": "Link", "linkType": "Asset", "id": "23qqdlTciMGm6IYy224euu" } }
|
Object |
raw JSON |
Array |
Array of any of the above, ex. [1.2, 2.9, 3.1]
|
Validations
linkContentType: ['dog']
|
Which content type IDs can be linked to. Array of strings. |
|
Predefined option set for this field, i.e. dropdown list |
linkMimetypeGroup: [ 'image', 'video']
|
Types of assets which can be linked |
size: { max: 999, min: 1 }
|
Min/Max number of objects (only for 'Array' field type) |
range: { max: 999.9, min: 1 }
|
Min/Max value of numeric field ('Integer' or 'Number') |
regexp: { pattern: "^such", flags: "i" }
|
Regex that the string field must match ('Symbol' or 'Text') |
|
No other entries have the same field value. Ex. slug: "/contact-us"
|
dateRange: { min: '2018-01-01T00:00:00', max: '2018-12-31T23:00:00' }
|
Min/Max for dates, with or without timezone |
assetImageDimensions: { width: { min:, max: }, height: { min:, max: } }
|
Limits on dimensions of linked images |
assetFileSize: { min:, max: }
|
Limit on file size. 1kb = 1024
|
message |
Custom error message for this validation |
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets