Entry

Entry

Source:
An entry is the actual piece of content created using one of the defined content types. Read more about Entries.

Methods

(static) update(locale) → {Promise.<Entry.Entry>}

Source:
The Create an entry call creates a new entry for the selected content type.
Examples
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('uid').fetch()
.then((entry) => {
 entry.title = 'My New Entry'
 entry.description = 'Entry description'
 return entry.update()
})
.then((entry) => console.log(entry))
// To Localize Entry pass locale in parameter
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('uid').fetch()
.then((entry) => {
 entry.title = 'My New Entry'
 entry.description = 'Entry description'
 return entry.update({ locale: 'en-at' })
})
.then((entry) => console.log(entry))
// To update entry with asset field
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('uid').fetch()
.then((entry) => {
 entry.title = 'My New Entry'
 entry.file = entry.file.uid // for single asset pass asset uid to entry asset field value
 entry.multiple_file = ['asset_uid_1', 'asset_uid_2'] // for multiple asset pass array of asset uid to entry asset field values
 return entry.update({ locale: 'en-at' })
})
.then((entry) => console.log(entry))
// To update entry with reference field
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('uid').fetch()
.then((entry) => {
 entry.title = 'My New Entry'
 entry.reference = entry.reference.uid // for single reference pass reference uid to entry reference field value
 entry.multiple_reference = ['reference_uid_1', 'reference_uid_2'] // for multiple reference pass array of reference uid to entry reference field values
 entry.multiple_content_type_reference = [{_content_type_uid: 'content_type_uid_1', uid: 'reference_uid_1'}, {_content_type_uid: 'content_type_uid_2', uid: 'reference_uid_2'}] // for multiple reference pass array of reference uid to entry reference field values
 return entry.update({ locale: 'en-at' })
})
.then((entry) => console.log(entry))
Parameters:
Name Type Description
locale Locale code to localized entry
Returns:
Promise for Entry instance
Type
Promise.<Entry.Entry>

(static) delete() → {Object}

Source:
The Delete an entry call is used to delete a specific entry from a content type.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('uid').delete()
.then((response) => console.log(response.notice))
Returns:
Response Object.
Type
Object

(static) fetch(version, locale, include_workflow, include_publish_details) → {Promise.<Entry.Entry>}

Source:
The fetch Entry call fetches Entry details.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('uid').fetch()
.then((entry) => console.log(entry))
Parameters:
Name Type Description
version Int Enter the version number of the entry that you want to retrieve. However, to retrieve a specific version of an entry, you need to keep the environment parameter blank.
locale Int Enter the code of the language of which the entries need to be included. Only the entries published in this locale will be displayed.
include_workflow Int Enter 'true' to include the workflow details of the entry.
include_publish_details Int Enter 'true' to include the publish details of the entry.
Returns:
Promise for Entry instance
Type
Promise.<Entry.Entry>

(static) publish() → {Promise.<Object>}

Source:
The Publish an asset call is used to publish a specific version of an asset on the desired environment either immediately or at a later date/time.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

const entry = {
 "locales": [
             "en-us"
             ],
  "environments": [
               "development"
              ]
}

client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('uid').publish({ publishDetails: entry, locale: "en-us", version: 1, scheduledAt: "2019-02-08T18:30:00.000Z"})
.then((response) => console.log(response.notice))
Returns:
Response Object.
Type
Promise.<Object>

(static) unpublish() → {Promise.<Object>}

Source:
The Replace asset call will replace an existing asset with another file on the stack.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

const entry = {
 "locales": [
             "en-us"
             ],
  "environments": [
               "development"
              ]
}

client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('uid').unpublish({ publishDetails: entry, locale: "en-us", version: 1, scheduledAt: "2019-02-08T18:30:00.000Z"})
.then((response) => console.log(response.notice))
Returns:
Response Object.
Type
Promise.<Object>

(static) publishRequest(publishing_rule, locale) → {Promise.<Object>}

Source:
This multipurpose request allows you to either send a publish request or accept/reject a received publish request.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

const publishing_rule = {
"uid": "uid",
"action": "publish" //(‘publish’, ‘unpublish’, or ’both’)
"status": 1, //(this could be ‘0’ for Approval Requested, ‘1’ for ‘Approval Accepted’, and ‘-1’ for ‘Approval Rejected’),
"notify": false,
comment": "Please review this."
}
client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('uid').publishRequest({ publishing_rule, locale: 'en-us'})
.then((response) => console.log(response.notice))
Parameters:
Name Type Description
publishing_rule Object Details for the publish request
locale String Enter the code of the locale that the entry belongs to.
Returns:
Response Object.
Type
Promise.<Object>

(static) setWorkflowStage(publishing_rule, locale) → {Promise.<Object>}

Source:
The Set Entry Workflow Stage request allows you to either set a particular workflow stage of an entry or update the workflow stage details of an entry.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

const workflow_stage = {
   "comment": "Workflow Comment",
   "due_date": "Thu Dec 01 2018",
   "notify": false,
   "uid": "workflow_stage_uid",
   "assigned_to": [{
     "uid": "user_uid",
     "name": "Username",
     "email": "user_email_id"
     }],
   "assigned_by_roles": [{
   "uid": "role_uid",
   "name": "Role name"
 }]
}
client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('uid').setWorkflowStage({ workflow_stage, locale: 'en-us'})
.then((response) => console.log(response.notice));
Parameters:
Name Type Description
publishing_rule Object Details for the publish request
locale String Enter the code of the locale that the entry belongs to.
Returns:
Response Object.
Type
Promise.<Object>

(static) create() → {Promise.<Entry.Entry>}

Source:
The Create an entry call creates a new entry for the selected content type.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
const entry  = {
 title: 'Sample Entry',
 url: '/sampleEntry',
 file = asset_uid, // for single asset pass asset uid to entry asset field value
 multiple_file = ['asset_uid_1', 'asset_uid_2'], // for multiple asset pass array of asset uid to entry asset field values
 reference: reference.uid, // for single reference pass reference uid to entry reference field value
 multiple_reference: ['reference_uid_1', 'reference_uid_2'], // for multiple reference pass array of reference uid to entry reference field values
 multiple_content_type_reference: [{_content_type_uid: 'content_type_uid_1', uid: 'reference_uid_1'}, {_content_type_uid: 'content_type_uid_2', uid: 'reference_uid_2'}] // for multiple reference pass array of reference uid to entry reference field values
}
client.stack().contentType('content_type_uid').entry().create({ entry })
.then((entry) => console.log(entry))
Returns:
Promise for Entry instance
Type
Promise.<Entry.Entry>

(static) query(locale, include_workflow, include_publish_details, query) → {Array.<Entry>}

Source:
The Query on Entry will allow to fetch details of all or specific Entry
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack().contentType('content_type_uid').entry().query({ query: { title: 'Entry title' } }).find()
.then((entries) => console.log(entries))
Parameters:
Name Type Description
locale Int Enter the code of the language of which the entries need to be included. Only the entries published in this locale will be displayed.
include_workflow Int Enter 'true' to include the workflow details of the entry.
include_publish_details Int Enter 'true' to include the publish details of the entry.
query Object Queries that you can use to fetch filtered results.
Returns:
Array of Entry.
Type
Array.<Entry>

(static) import(entry, locale, overwrite)

Source:
The Import Entry calls given below help you to import entries by uploading JSON files.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry()
.import({
 entry: 'path/to/file.json',
 overwrite: true
})
.then((entry) => console.log(entry))
Parameters:
Name Type Description
entry String Select the JSON file of the entry that you wish to import.
locale String Enter the code of the language to import the entry of that particular language.
overwrite Boolean Select 'true' to replace an existing entry with the imported entry file.