- Source:
Entry instances
Type Definitions
Entry
- Source:
Properties:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sys |
Meta.Sys | Standard system metadata with additional entry specific properties
Properties
|
||||||||||||
fields |
Object.<EntryFields.Field> | Object with content for each field | ||||||||||||
toPlainObject() |
function | Returns this Entry as a plain JS object |
Methods
(static) archive() → {Promise.<Entry>}
- Source:
Archives the object
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getEntry('<entry_id>'))
.then((entry) => entry.archive())
.then((entry) => console.log(`Entry ${entry.sys.id} archived.`))
.catch(console.error)
Returns:
Object returned from the server with updated metadata.
- Type
- Promise.<Entry>
(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.getEntry('<entry_id>'))
.then((entry) => entry.delete())
.then(() => console.log(`Entry deleted.`))
.catch(console.error)
Returns:
Promise for the deletion. It contains no data, but the Promise error case should be handled.
- Type
- Promise
(static) getSnapshot(snapshotId)
- Source:
Gets a snapshot of an entry
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getEntry('<entry_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 an entry
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getEntry('<entry_id>'))
.then((entry) => entry.getSnapshots())
.then((snapshots) => console.log(snapshots.items))
.catch(console.error)
Returns:
Promise
(static) isArchived() → {boolean}
- Source:
Checks if entry is archived. This means it's not exposed to the Delivery/Preview APIs.
Returns:
- Type
- boolean
(static) isDraft() → {boolean}
- Source:
Checks if the entry is in draft mode. This means it is not published.
Returns:
- Type
- boolean
(static) isPublished() → {boolean}
- Source:
Checks if the entry is published. A published entry might have unpublished changes (@see {Entry.isUpdated})
Returns:
- Type
- boolean
(static) isUpdated() → {boolean}
- Source:
Checks if the entry is updated. This means the entry was previously published but has unpublished changes.
Returns:
- Type
- boolean
(static) publish() → {Promise.<Entry>}
- 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.getEntry('<entry_id>'))
.then((entry) => entry.publish())
.then((entry) => console.log(`Entry ${entry.sys.id} published.`))
.catch(console.error)
Returns:
Object returned from the server with updated metadata.
- Type
- Promise.<Entry>
(static) unarchive() → {Promise.<Entry>}
- Source:
Unarchives the object
Example
const contentful = require('contentful-management')
const client = contentful.createClient({
accessToken: '<content_management_api_key>'
})
client.getSpace('<space_id>')
.then((space) => space.getEntry('<entry_id>'))
.then((entry) => entry.unarchive())
.then((entry) => console.log(`Entry ${entry.sys.id} unarchived.`))
.catch(console.error)
Returns:
Object returned from the server with updated metadata.
- Type
- Promise.<Entry>
(static) unpublish() → {Promise.<Entry>}
- 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.getEntry('<entry_id>'))
.then((entry) => entry.unpublish())
.then((entry) => console.log(`Entry ${entry.sys.id} unpublished.`))
.catch(console.error)
Returns:
Object returned from the server with updated metadata.
- Type
- Promise.<Entry>
(static) update() → {Promise.<Entry>}
- 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.getEntry('<entry_id>'))
.then((entry) => {
entry.fields.title['en-Us'] = 'New entry title'
return entry.update()
})
.then((entry) => console.log(`Entry ${entry.sys.id} updated.`))
.catch(console.error)
Returns:
Object returned from the server with updated changes.
- Type
- Promise.<Entry>