migration.createContentType('dog') |
Create a new content type with given id
|
.name('Dog') |
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 |
dog.createField('owner') |
Create a field
|
.name('Owner') |
Set display name in Contentful editor
|
.type('Symbol') |
Set field type - see below
|
.items(options) |
Only when type is 'Array' - define type of items in array
|
.linkType('Entry') |
Only when type is 'Link' - define type to link to
|
.validations([ { ... } ]) |
Set validations on a field
|
.required(true) |
Set field as required
|
.localized(true) |
Set field as having translations
|
.disabled(true) |
Set field to be not editable
|
.omitted(true) |
Set field to not be sent over CDN
|
.deleted(true) |
Deletes the field
|
|
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
|
true or false |
|
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] |
linkContentType: ['dog'] |
Which content type IDs can be linked to. Array of strings.
|
in: ['TX', 'OK'] |
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')
|
unique: true |
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
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.