- Source:
Content Type instances
Type Definitions
ContentType
- Source:
Properties:
Name | Type | Description |
---|---|---|
sys |
Meta.Sys | System metadata |
name |
string | |
description |
string | |
displayField |
string | Field used as the main display field for Entries |
fields |
Array.<Field> | All the fields contained in this Content Type |
toPlainObject() |
function | Returns this Content Type as a plain JS object |
Methods
(static) delete() → {Promise}
- Source:
Deletes this object on the server.
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getContentType('<contentType_id>'))
.then((contentType) => contentType.delete())
.then(() => console.log('contentType deleted'))
.catch(console.error)
Returns:
Promise for the deletion. It contains no data, but the Promise error case should be handled.
- Type
- Promise
(static) getEditorInterface() → {Promise.<EditorInterface.EditorInterface>}
- Source:
Gets the editor interface for the object
Important note: The editor interface only represent a published contentType.
To get the most recent representation of the contentType make sure to publish it first
Important note: The editor interface only represent a published contentType.
To get the most recent representation of the contentType make sure to publish it first
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getContentType('<contentType_id>'))
.then((contentType) => contentType.getEditorInterface())
.then((editorInterface) => console.log(editorInterface.contorls))
.catch(console.error)
Returns:
Object returned from the server with the current editor interface.
- Type
- Promise.<EditorInterface.EditorInterface>
(static) getSnapshot(snapshotId)
- Source:
Gets a snapshot of a contentType
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getContentType('<content_type-id>'))
.then((entry) => entry.getSnapshot('<snapshot-id>'))
.then((snapshot) => console.log(snapshot))
.catch(console.error)
Parameters:
Name | Type | Description |
---|---|---|
snapshotId |
string | Id of the snapshot |
Returns:
Promise
(static) getSnapshots()
- Source:
Gets all snapshots of a contentType
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getContentType('<contentType_id>'))
.then((entry) => entry.getSnapshots())
.then((snapshots) => console.log(snapshots.items))
.catch(console.error)
Returns:
Promise
(static) isDraft() → {boolean}
- Source:
Checks if the contentType is in draft mode. This means it is not published.
Returns:
- Type
- boolean
(static) isPublished() → {boolean}
- Source:
Checks if the contentType is published. A published contentType might have unpublished changes (@see {ContentType.isUpdated})
Returns:
- Type
- boolean
(static) isUpdated() → {boolean}
- Source:
Checks if the contentType is updated. This means the contentType was previously published but has unpublished changes.
Returns:
- Type
- boolean
(static) publish() → {Promise.<ContentType>}
- Source:
Publishes the object
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getContentType('<contentType_id>'))
.then((contentType) => contentType.publish())
.then((contentType) => console.log(`${contentType.sys.id} is published`))
.catch(console.error)
Returns:
Object returned from the server with updated metadata.
- Type
- Promise.<ContentType>
(static) unpublish() → {Promise.<ContentType>}
- Source:
Unpublishes the object
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getContentType('<contentType_id>'))
.then((contentType) => contentType.unpublish())
.then((contentType) => console.log(`${contentType.sys.id} is unpublished`))
.catch(console.error)
Returns:
Object returned from the server with updated metadata.
- Type
- Promise.<ContentType>
(static) update() → {Promise.<ContentType>}
- Source:
Sends an update to the server with any changes made to the object's properties
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getContentType('<contentType_id>'))
.then((contentType) => {
contentType.name = 'New name'
return contentType.update()
})
.then(contentType => console.log(contentType))
.catch(console.error)
Returns:
Object returned from the server with updated changes.
- Type
- Promise.<ContentType>