new Entry(uid) → {Entry}
Creates an instance of `Entry`.
An initializer is responsible for creating Entry object.
Parameters:
Name | Description |
---|---|
uid |
uid of the entry |
Example
let Entry = Stack.ContentType('example').Entry('entry_uid');
Methods
includeFallback() → {Asset}
Include the fallback locale publish content, if specified locale content is not publish.
Example
stack.ContentType(contentType_uid).Entry(entry_uid).includeFallback().fetch()
only(keyopt, values) → {Entry}
Displays values of only the specified fields of entries or assets in the response
Parameters:
Name | Attributes | Default | Description |
---|---|---|---|
key |
<optional> |
BASE | Assets:
Retrieves specified field of asset |
|
Entries:
- retrieves default fields of the schema. - referenced_content-type-uid : retrieves fields of the referred content type. |
||
values |
array of fields that you want to display in the response |
Examples
Stack.ContentType('contentTypeUid').Query().only('title').toJSON().find()
Stack.ContentType('contentTypeUid').Query().only(['title','description']).toJSON().find()
Stack.ContentType('contentTypeUid').Query().includeReference('reference_field_uid').only('reference_field_uid','title').toJSON().find()
Stack.ContentType('contentTypeUid').Query().includeReference('reference_field_uid').only('reference_field_uid', ['title', 'description']).toJSON().find()
except(keyopt, values) → {Entry}
Displays all data of an entries or assets excluding the data of the specified fields.
Parameters:
Name | Attributes | Default | Description |
---|---|---|---|
key |
<optional> |
BASE | BASE (default value) - retrieves default fields of the schema. - referenced_content-type-uid - retrieves fields of the referred content type. |
values |
array of fields that you want to skip in the response |
Examples
Stack.ContentType('contentTypeUid').Query().except('title').toJSON().find()
Stack.ContentType('contentTypeUid').Query().except(['title','description']).toJSON().find()
Stack.ContentType('contentTypeUid').Query().includeReference('reference_field_uid').except('reference_field_uid','title').toJSON().find()
Stack.ContentType('contentTypeUid').Query().includeReference('reference_field_uid').except('reference_field_uid', ['title', 'description']).toJSON().find()
includeReference() → {Entry}
Fetches the entire content of referenced entry(ies). Read More
Examples
var Query = Stack.ContentType(contentTypes.source).Query();
Query
.includeReference(['reference_field_uid', 'other_reference_field_uid'])
.toJSON()
.find()
.then(function success(entries) {
//'entries' is an object used to retrieve data including reference entries.
})
var Query = Stack.ContentType(contentTypes.source).Query();
Query
.includeReference(['reference_field_uid', 'reference_field_uid.child_reference_field_uid'])
.toJSON()
.find()
.then(function success(entries) {
//'entries' is an object used to retrieve data including reference entries.
})
var Query = Stack.ContentType(contentTypes.source).Query();
Query
.includeReference('reference_field_uid')
.toJSON()
.find()
.then(function success(entries) {
//'entries' is an object used to retrieve data including particular reference using reference_uid.
})
language(language_code) → {Entry}
Sets the language code of which you want to retrieve data.
Parameters:
Name | Description |
---|---|
language_code |
language code. e.g. 'en-us', 'ja-jp', etc. |
Example
let data = Stack.ContentType(contentTypeUid).Entry(entryUid).language('ja-jp').fetch()
data
.then(function(result) {
// 'result' is an object used to retrieve data of ja-jp language.
}, function(error) {
// error function
})
addQuery(key, value) → {Entry}
Adds query to Entry object
Parameters:
Name | Description |
---|---|
key |
key of the query |
value |
value of the query |
Example
Stack.ContentType(contentTypeUid).Entry(entry_uid).addQuery('include_schema',true)
includeEmbeddedItems() → {Entry}
Include Embedded Objects (Entries and Assets) along with entry/entries details.
Example
Stack.ContentType("contentType_uid").Entry("entry_uid").includeEmbeddedItems().fetch()
includeSchema() → {Entry}
Include schema of the current content type along with entry/entries details.
- Deprecated:
- since version 3.3.0
Example
Stack.ContentType("contentType_uid").Entry("entry_uid").includeSchema().fetch()
includeReferenceContentTypeUid() → {Entry}
This method also includes the content type UIDs of the referenced entries returned in the response.
Examples
Stack.ContentType("contentType_uid").Entry("entry_uid").includeReferenceContentTypeUID().fetch()
Query = Stack.ContentType("contentType_uid").Entry("entry_uid").includeReferenceContentTypeUID().fetch()
Query
.toJSON()
.then(function (result) {
let value = result.get(field_uid)
},function (error) {
// error function
})
includeFallback() → {Entry}
Include the fallback locale publish content, if specified locale content is not publish.
Example
stack.ContentType(contentType_uid).Entry(entry_uid).includeFallback().fetch()
includeBranch() → {Entry}
Include the Branch for publish content.
Example
stack.ContentType(contentType_uid).Entry(entry_uid).includeBranch().fetch()
includeContentType() → {Entry}
Include the details of the content type along with the entry/entries details.
Example
stack.ContentType(contentType_uid).Entry(entry_uid).includeContentType().fetch()
includeOwner() → {Entry}
Includes the owner details of the entry/entries
Example
stack.ContentType(contentType_uid).Entry(entry_uid).includeOwner().fetch()
toJSON() → {Entry}
Converts your response into plain JavasScript object.Supports both entry and asset queries.
Example
Query = Stack.ContentType(contentTypeUid).Entry(entryUid).fetch()
Query
.toJSON()
.then(function (result) {
let value = result.get(field_uid)
},function (error) {
// error function
})
addParam() → {Entry}
Includes query parameters in your queries.
Example
var data = Stack.ContentType(contentTypeUid).Entry(entryUid).addParam('include_count', 'true').fetch()
data.then(function (result) {
// 'result' is an object which content the data including count in json object form
},function (error) {
// error function
})
fetch() → {promise}
Fetches a particular entry based on the provided entry UID.
Examples
Stack.ContentType(contentTypeUid).Entry(entryUid).toJSON().fetch()
Stack.ContentType(contentTypeUid).Entry(entryUid).toJSON().fetch({
})