new Entry(uid) → {Entry}
Creates an instance of `Entry`.
Parameters:
Name | Description |
---|---|
uid |
uid of the entry |
Example
let Entry = Stack.ContentType('example').Entry('entry_uid');
Methods
includeFallback() → {Asset}
Example
stack.ContentType(contentType_uid).Entry(entry_uid).includeFallback().fetch()
only(keyopt, values) → {Entry}
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
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.
Stack.ContentType('contentTypeUid').Query().only('title').toJSON().find()
The only function with an array of field_uids will include multiple fields for each entry and exclude the data of all other fields.
Stack.ContentType('contentTypeUid').Query().only(['title','description']).toJSON().find()
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.
Stack.ContentType('contentTypeUid').Query().includeReference('reference_field_uid').only('reference_field_uid','title').toJSON().find()
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.
Stack.ContentType('contentTypeUid').Query().includeReference('reference_field_uid').only('reference_field_uid', ['title', 'description']).toJSON().find()
except(keyopt, values) → {Entry}
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
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.
Stack.ContentType('contentTypeUid').Query().except('title').toJSON().find()
The except function with an array of field_uids will except multiple fields for each entry and include the data of all other fields.
Stack.ContentType('contentTypeUid').Query().except(['title','description']).toJSON().find()
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.
Stack.ContentType('contentTypeUid').Query().includeReference('reference_field_uid').except('reference_field_uid','title').toJSON().find()
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.
Stack.ContentType('contentTypeUid').Query().includeReference('reference_field_uid').except('reference_field_uid', ['title', 'description']).toJSON().find()
includeReference() → {Entry}
Examples
.includeReference with reference_field_uids as array
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.
})
.includeReference with reference_field_uids and its children reference
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.
})
.includeReference with reference_field_uids
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}
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}
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}
Example
Stack.ContentType("contentType_uid").Entry("entry_uid").includeEmbeddedItems().fetch()
includeSchema() → {Entry}
- Deprecated:
- since version 3.3.0
Example
Stack.ContentType("contentType_uid").Entry("entry_uid").includeSchema().fetch()
includeReferenceContentTypeUid() → {Entry}
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}
Example
stack.ContentType(contentType_uid).Entry(entry_uid).includeFallback().fetch()
includeBranch() → {Entry}
Example
stack.ContentType(contentType_uid).Entry(entry_uid).includeBranch().fetch()
includeContentType() → {Entry}
Example
stack.ContentType(contentType_uid).Entry(entry_uid).includeContentType().fetch()
includeOwner() → {Entry}
Example
stack.ContentType(contentType_uid).Entry(entry_uid).includeOwner().fetch()
toJSON() → {Entry}
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}
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}
Examples
Stack.ContentType(contentTypeUid).Entry(entryUid).toJSON().fetch()
Stack.ContentType(contentTypeUid).Entry(entryUid).toJSON().fetch({
})