Skip to content

Commit a30a2cd

Browse files
Merge pull request #18 from contentstack/multiple-ct-reference
Support Multi-ContentType reference feature
2 parents 7b40280 + 742112e commit a30a2cd

File tree

5 files changed

+74
-5
lines changed

5 files changed

+74
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "contentstack",
3-
"version": "3.6.0",
3+
"version": "3.7.0",
44
"description": "Contentstack Javascript SDK",
55
"homepage": "https://www.contentstack.com/",
66
"author": {

src/core/modules/assets.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Query from './query';
66
* @class
77
Assets
88
* @summary Creates an instance of `Assets`.
9-
* @description Retrieves the asset based on the specified UID
9+
* @description Retrieves all assets of a stack by default. To retrieve a single asset, specify its UID.
1010
* @param {String} uid - uid of asset you want to retrieve
1111
* @example
1212
* let data = Stack.Assets('bltsomething123').toJSON().fetch()
@@ -16,6 +16,14 @@ import Query from './query';
1616
* }, function(error) {
1717
* // error function
1818
* })
19+
* @example
20+
* let data = Stack.Assets().toJSON().find()
21+
* data
22+
* .then(function(result) {
23+
* // ‘result’ will display all assets present in stack
24+
* }, function(error) {
25+
* // error function
26+
* })
1927
* @returns {Assets}
2028
* @instance
2129
*/

src/core/modules/entry.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,29 @@ export default class Entry {
193193
return this;
194194
}
195195

196+
/**
197+
* @method includeReferenceContentTypeUid
198+
* @memberOf Entry
199+
* @description This method also includes the content type UIDs of the referenced entries returned in the response.
200+
* @example Stack.ContentType("contentType_uid").Entry("entry_uid").includeReferenceContentTypeUID().fetch()
201+
* @example
202+
* Query = Stack.ContentType("contentType_uid").Entry("entry_uid").includeReferenceContentTypeUID().fetch()
203+
* Query
204+
* .toJSON()
205+
* .then(function (result) {
206+
* let value = result.get(field_uid)
207+
* },function (error) {
208+
* // error function
209+
* })
210+
* @returns {Entry}
211+
* @instance
212+
*/
213+
includeReferenceContentTypeUID() {
214+
this._query['include_reference_content_type_uid'] = true;
215+
return this;
216+
}
217+
218+
196219
/**
197220
* @method includeContentType
198221
* @memberOf Entry

src/core/modules/query.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,28 @@ export default class Query extends Entry {
497497
}
498498
}
499499

500+
/**
501+
* @method includeReferenceContentTypeUid
502+
* @memberOf Query
503+
* @description This method also includes the content type UIDs of the referenced entries returned in the response.
504+
* @example Stack.ContentType("contentType_uid").Query().includeReferenceContentTypeUID().find()
505+
* @example
506+
* let blogQuery = Stack.ContentType("contentType_uid").Query();
507+
* let data = blogQuery.includeReferenceContentTypeUID().find()
508+
* data.then(function(result) {
509+
* // ‘result’ contains a list of entries in which content type UIDs is present.
510+
* },function (error) {
511+
* // error function
512+
* })
513+
* @returns {Query}
514+
* @instance
515+
*/
516+
includeReferenceContentTypeUID() {
517+
this._query['include_reference_content_type_uid'] = true;
518+
return this;
519+
}
520+
521+
500522
/**
501523
* @method includeCount
502524
* @memberOf Query
@@ -530,7 +552,6 @@ export default class Query extends Entry {
530552
* @returns {Query}
531553
* @instance
532554
*/
533-
534555
addParam(key, value) {
535556
if (key && value && typeof key === 'string' && typeof value === 'string') {
536557
this._query[key] = value;
@@ -595,7 +616,7 @@ export default class Query extends Entry {
595616
* })
596617
* @returns {Query}
597618
* @instance
598-
*/
619+
*/
599620
search(value) {
600621
if (value && typeof value === 'string') {
601622
this._query['typeahead'] = value;
@@ -663,6 +684,7 @@ export default class Query extends Entry {
663684
query: this._query
664685
}
665686
};
687+
666688
return Utils.sendRequest(this);
667689
}
668690

src/core/stack.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,23 @@ export default class Stack {
282282
* @method Assets
283283
* @memberOf Stack
284284
* @param {String} uid - uid of the asset
285-
* @description Retrieves the asset based on the specified UID
285+
* @description Retrieves all assets of a stack by default. To retrieve a single asset, specify its UID.
286+
* @example
287+
* let data = Stack.Assets('bltsomething123').toJSON().fetch()
288+
* data
289+
* .then(function(result) {
290+
* // ‘result’ is a single asset object of specified uid
291+
* }, function(error) {
292+
* // error function
293+
* })
294+
* @example
295+
* let data = Stack.Assets().toJSON().find()
296+
* data
297+
* .then(function(result) {
298+
* // ‘result’ will display all assets present in stack
299+
* }, function(error) {
300+
* // error function
301+
* })
286302
* @returns {Assets}
287303
* @instance
288304
*/

0 commit comments

Comments
 (0)