Entry

View as Markdown

Entry

An initializer is responsible for creating Entry object.
NameTypeDescription
uid (required)string

Uid of the entry

language

Sets the language code of which you want to retrieve data.
NameTypeDescription
language_codestring

language code. e.g. 'en-us', 'ja-jp', etc.

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').language('language_code').toJSON().fetch();

addParam

Includes query parameters in your queries.

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').addParam('include_count', 'true').toJSON().fetch()

addQuery

Adds query to Entry object

NameTypeDescription
keystring

Key of the query

valueany

Value of the query

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').addQuery('include_content_type', true).toJSON().fetch();

only

Displays values of only the specified fields of entries or assets in the response
NameTypeDescription
valuesstring|array

The only function with field_uid will include the data of only the specified fields for each entry and exclude the data of all other fields.

import Contentstack from 'contentstack'; 

const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').only('title').toJSON().fetch();

The only function with an array of field_uids will include multiple fields for each entry and exclude the data of all other fields.

import Contentstack from 'contentstack';

const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').only(['title', 'description']).toJSON().fetch();

In only, we have the only with a reference parameter, where you need to enter the UID of the reference field in place of "reference_field_uid", and the second parameter to include the data of only the specified field_uid for each entry and exclude the data of all other fields.

import Contentstack from 'contentstack';

const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').includeReference('reference_field_uid').only('reference_field_uid','title').toJSON().fetch();

In only, we have the only with a reference parameter with an array, where you need to enter the UID of the reference field in place of "reference_field_uid", and the second parameter with an array of fields to include the data of only the specified array of field_uids for each entry and exclude the data of all other fields.

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').includeReference('reference_field_uid').only('reference_field_uid',['title', 'description']).toJSON().fetch();

except

Displays all data of an entries or assets excluding the data of the specified fields.
NameTypeDescription
valuesstring|array

The except function with field_uid will exclude the data of only the specified fields for each entry and includes the data of all other fields.

import Contentstack from 'contentstack'; 

const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').except('title').toJSON().fetch();

The except function with an array of field_uids will except multiple fields for each entry and include the data of all other fields.

import Contentstack from 'contentstack';

const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').except(['title', 'description']).toJSON().fetch();

In except, we have the only with a reference parameter, where you need to enter the UID of the reference field in place of "reference_field_uid", and the second parameter to except the data of only the specified field_uid for each entry and include the data of all other fields.

import Contentstack from 'contentstack';

const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').includeReference('reference_field_uid').except('reference_field_uid','title').toJSON().fetch();

In except, we have the only with a reference parameter with an array, where you need to enter the UID of the reference field in place of "reference_field_uid", and the second parameter with an array of fields to except the data of only the specified array of field_uids for each entry and include the data of all other fields.

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').includeReference('reference_field_uid').except('reference_field_uid',['title', 'description']).toJSON().fetch();

includeReference

Fetches the entire content of referenced entry.

NameTypeDescription
valuestring|array

Include Reference with reference_field_uids as array:

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').includeReference(['reference_field_uid','other_reference_field_uid']).toJSON().fetch();

Include Reference with reference_field_uids and its children reference

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').includeReference(['reference_field_uid', 'reference_field_uid.child_reference_field_uid']).toJSON().fetch();

Include Reference with reference_field_uid:

import Contentstack from 'contentstack';


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').includeReference('reference_field_uid').toJSON().fetch();

includeEmbeddedItems

Include Embedded Objects (Entries and Assets) along with entry/entries details.
import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').includeEmbeddedItems().toJSON().fetch();

includeContentType

Include the details of the content type along with the entry/entries details.

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').includeContentType().toJSON().fetch();

includeBranch

Include the Branch for publish content.

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

const result = await Stack.ContentType('content_type_uid').Entry('entry_uid').includeBranch().toJSON().fetch();

includeFallback

Include the fallback locale publish content, if specified locale content is not publish.

import Contentstack from 'contentstack'


const Stack = Contentstack.Stack({'api_key': 'api_key', 'delivery_token': 'delivery_token', 'environment': 'environment'});

Stack.ContentType('content_type_uid;).Entry('entry_uid').includeFallback().fetch()