Skip to content

Commit 19d19ad

Browse files
Updated a Reference doc
1 parent cbbca91 commit 19d19ad

File tree

7 files changed

+65
-112
lines changed

7 files changed

+65
-112
lines changed

js-sdk-reference.zip

-495 Bytes
Binary file not shown.

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.5.0",
3+
"version": "3.5.1",
44
"description": "Contentstack Javascript SDK",
55
"homepage": "https://www.contentstack.com/",
66
"author": {

src/core/contentstack.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ class Contentstack {
2424

2525
/**
2626
* @method Stack
27-
* @description Initialize "Contentstack" Stack javascript-SDK instance
27+
* @description Initialize an instance of ‘Stack’
2828
* @api public
2929
* @example
30-
* var Stack = Contentstack.Stack('api_key', 'access_token', 'environment');
31-
* OR
32-
* var Stack = Contentstack.Stack({
33-
* 'api_key':'bltsomethingapikey',
34-
* 'access_token':'bltsomethongtoken',
35-
* 'environment':'environment_name'
36-
* });
30+
*var Stack = Contentstack.Stack('api_key', 'delivery_token', 'environment');
31+
OR
32+
*var Stack = Contentstack.Stack({
33+
* 'api_key':'stack_api_key',
34+
* 'access_token':'stack_delivery_token',
35+
* 'environment':'environment_name'
36+
* });
3737
*
3838
* @returns {Stack}
3939
*/

src/core/modules/assets.js

Lines changed: 6 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Stack from '../stack';
33
import Query from './query';
44

55
/**
6-
* @summary Creates an instance of `Assets`.
6+
* @summary Creates an instance of 'Assets'.
77
* @description An initializer is responsible for creating Asset object.
88
* @param {String} uid - uid of the asset
99
* @example
@@ -13,55 +13,18 @@ import Query from './query';
1313
*/
1414
export default class Assets {
1515
constructor() {
16-
this._query = {};
17-
/**
18-
* @method only
19-
* @description This method is use to show the selected fields of the assets in resultset.
20-
* @param {String} [key=BASE] - single field in asset
21-
* @param {Array} values - array of fields to be show in resultset
22-
* @example
23-
* <caption> .only with field uid </caption>
24-
* Assets().only('title')
25-
* @example
26-
* <caption> .only with field uid </caption>
27-
* Assets().only('BASE','title')
28-
* @example
29-
* <caption> .only with field uids(array) </caption>
30-
* Assets().only(['title','description'])
31-
* @returns {Asset}
32-
*/
16+
this._query = {};
3317
this.only = Utils.transform('only');
3418
return this;
3519
}
3620

37-
/**
38-
* @method toJSON
39-
* @description Converts your response into plain JavasScript object.
40-
* @example
41-
* assetQuery
42-
* .toJSON()
43-
* .then(function (result) {
44-
* let value = result.get(field_uid)
45-
* },function (error) {
46-
* // error function
47-
* })
48-
* @returns {Object}
49-
*/
21+
5022
toJSON() {
5123
this.tojson = true;
5224
return this;
5325
}
5426

55-
/**
56-
* @method AddParam
57-
* @description Includes query parameters in your query.
58-
* @example var data = blogQuery.addParam('include_count', 'true').toJSON().fetch()
59-
* data.then(function (result) {
60-
* // result contents count in JSON object form
61-
* },function (error) {
62-
* // error function
63-
* })
64-
*/
27+
6528
addParam(key, value) {
6629
if (key && typeof key === 'string' && value && typeof value === 'string') {
6730
this._query[key] = value;
@@ -71,12 +34,8 @@ export default class Assets {
7134
}
7235
}
7336

74-
/**
75-
* @method fetch
76-
* @description Fetches a particular Asset based on the provided assets UID.
77-
* @example
78-
* Stack.Assets('bltsomething123').toJSON().fetch()
79-
*/
37+
38+
8039
fetch() {
8140
if (this.asset_uid) {
8241
this.requestParams = {

src/core/modules/entry.js

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ export default class Entry {
1515
this._query = {};
1616
/**
1717
* @method only
18-
* @description Displays values of only the specified fields in the response
19-
* @param {String} [key=BASE] - BASE (default value) - retrieves default fields of the schema.
20-
- referenced content-type-uid - retrieves fields of the referred content type.
18+
* @description Displays values of only the specified fields of entries or assets in the response
19+
* @param {String} [key=BASE] - Assets: </br>
20+
* <p>Retrieves specified field of asset</p>
21+
* @param {String} - Entries:</br>
22+
* <p>- retrieves default fields of the schema.</p>
23+
* <p>- referenced_content-type-uid : retrieves fields of the referred content type.</p>
2124
* @param {Array} values - array of fields that you want to display in the response
2225
* @example
2326
* <caption> .only with field uid </caption>
@@ -35,11 +38,12 @@ export default class Entry {
3538
* <caption> .only with reference_field_uid and field uids(array) </caption>
3639
* blogEntry.includeReference('category').only('category', ['title', 'description'])
3740
* @returns {Entry}
41+
* @returns {Asset}
3842
*/
3943
this.only = Utils.transform('only');
4044
/**
4145
* @method except
42-
* @description Displays all data of an entry excluding the data of the specified fields.
46+
* @description Displays all data of an entries or assets excluding the data of the specified fields.
4347
* @param {String} [key=BASE] - BASE (default value) - retrieves default fields of the schema.
4448
- referenced_content-type-uid - retrieves fields of the referred content type.
4549
* @param {Array} values - array of fields that you want to skip in the response
@@ -134,7 +138,7 @@ export default class Entry {
134138

135139
/**
136140
* @method addQuery
137-
* @description Adds query to Entry object.
141+
* @description Adds query to Entry object
138142
* @param {String} key - key of the query
139143
* @param {String} value - value of the query
140144
* @example blogEntry.addQuery('include_schema',true)
@@ -150,9 +154,9 @@ export default class Entry {
150154
}
151155

152156
/**
153-
* @method IncludeSchema
157+
* @method includeSchema
154158
* @deprecated since verion 3.3.0
155-
* @description Include schema of the current contenttype along with entry/entries details.
159+
* @description Include schema of the current content type along with entry/entries details.
156160
* @example Stack.ContentType("contentType_uid").Entry("entry_uid").includeSchema().fetch()
157161
* @returns {Entry}
158162
*/
@@ -163,7 +167,7 @@ export default class Entry {
163167

164168
/**
165169
* @method includeContentType
166-
* @description Include the details of the contenttype along with the entry/entries details.
170+
* @description Include the details of the content type along with the entry/entries details.
167171
* @example blogEntry.includeContentType()
168172
* @returns {Entry}
169173
*/
@@ -185,9 +189,9 @@ export default class Entry {
185189

186190
/**
187191
* @method toJSON
188-
* @description This method is used to convert the result in to plain javascript object.
192+
* @description Converts your response into plain JavasScript object.Supports both entry and asset queries.
189193
* @example
190-
* blogEntry
194+
* Query
191195
* .toJSON()
192196
* .then(function (result) {
193197
* let value = result.get(field_uid)
@@ -203,10 +207,10 @@ export default class Entry {
203207

204208
/**
205209
* @method AddParam
206-
* @description AddParam method includes query parameter in query.
210+
* @description Includes query parameters in your queries. Supports both 'entries' and 'assets' queries.
207211
* @example var data = blogQuery.addParam('include_count', 'true').fetch()
208212
* data.then(function (result) {
209-
* // result is an object which content the data including count in json object form
213+
* // 'result' is an object which content the data including count in json object form
210214
* },function (error) {
211215
* // error function
212216
* })
@@ -223,9 +227,11 @@ export default class Entry {
223227

224228
/**
225229
* @method fetch
226-
* @description Fetches a particular entry based on the provided entry UID.
230+
* @description Fetches a particular entry/asset based on the provided entry UID/asset UID.
231+
* @example
232+
* Stack.blogEntry('entry_uid').toJSON().fetch()
227233
* @example
228-
* Stack.blogEntry('entry_uid').fetch()
234+
* Stack.Assets('assets_uid').toJSON().fetch()
229235
*/
230236
fetch() {
231237
if (this.entry_uid) {

src/core/modules/query.js

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ const _extend = {
8080

8181
/**
8282
* @summary
83-
* Creates an instance of `Query`.
83+
* Creates an instance of 'Query'.
8484
* @description
8585
* An initializer is responsible for creating Query object.
8686
* @example
@@ -103,7 +103,7 @@ export default class Query extends Entry {
103103
* @example let blogQuery = Stack().ContentType('example').Query();
104104
* let data = blogQuery.lessThan('created_at','2015-06-22').find()
105105
* data.then(function (result) {
106-
* // result content the data who's created_at date is less than '2015-06-22'
106+
* // result content the data who's 'created_at date' is less than '2015-06-22'
107107
* },function (error) {
108108
* // error function
109109
* })
@@ -119,7 +119,7 @@ export default class Query extends Entry {
119119
* @example let blogQuery = Stack().ContentType('example').Query();
120120
* let data = blogQuery.lessThanOrEqualTo('created_at','2015-06-22').find()
121121
* data.then(function (result) {
122-
* // result contain the data of entries where the created_at date will be less than or equalto '2015-06-22'.
122+
* // result contain the data of entries where the 'created_at' date will be less than or equalto '2015-06-22'.
123123
* },function (error) {
124124
* // error function
125125
* })
@@ -130,12 +130,12 @@ export default class Query extends Entry {
130130
* @method greaterThan
131131
* @description Retrieves entries in which the value for a field is greater than the provided value.
132132
* @param {String} key - uid of the field
133-
* @param {*} value - value used to match or compare.
133+
* @param {*} value - value used to match or compare
134134
* @example
135135
* let blogQuery = Stack().ContentType('example').Query();
136136
* let data = blogQuery.greaterThan('created_at','2015-03-12').find()
137137
* data.then(function(result) {
138-
* // result contains the data of entries where the created_at date will be greaterthan '2015-06-22'
138+
* // result contains the data of entries where the 'created_at' date will be greaterthan '2015-06-22'
139139
* },function (error) {
140140
* // error function
141141
* })
@@ -151,7 +151,7 @@ export default class Query extends Entry {
151151
* @example let blogQuery = Stack().ContentType('example').Query();
152152
* let data = blogQuery.greaterThanOrEqualTo('created_at','2015-03-12').find()
153153
* data.then(function(result) {
154-
* // result contains the data of entries where the created_at date will be greaterThan or equalto '2015-06-22'
154+
* // result contains the data of entries where the 'created_at' date will be greaterThan or equalto '2015-06-22'
155155
* },function (error) {
156156
* // error function
157157
* })
@@ -200,7 +200,7 @@ export default class Query extends Entry {
200200
* @example let blogQuery = Stack().ContentType('example').Query();
201201
* let data = blogQuery.notContainedIn('title', ['Demo', 'Welcome']).find()
202202
* data.then(function(result) {
203-
* // result contains the list of entries where value of the title field should not be either "Demo" or ‘Welcome’
203+
* // 'result' contains the list of entries where value of the title field should not be either "Demo" or ‘Welcome’
204204
* },function (error) {
205205
* // error function
206206
* })
@@ -243,7 +243,7 @@ export default class Query extends Entry {
243243
/**
244244
* @method ascending
245245
* @description Sort fetched entries in the ascending order with respect to a specific field.
246-
* @param {String} key - uid of the field
246+
* @param {String} key - field uid based on which the ordering will be done
247247
* @example let blogQuery = Stack().ContentType('example').Query();
248248
* let data = blogQuery.ascending('created_at').find()
249249
* data.then(function(result) {
@@ -298,7 +298,7 @@ export default class Query extends Entry {
298298
* @example let blogQuery = Stack().ContentType('example').Query();
299299
* let data = blogQuery.skip(5).find()
300300
* data.then(function(result) {
301-
* // result contains the list of data which is sorted in descending order on created_at bases.
301+
* // result contains the list of data which is sorted in descending order on 'created_at' bases.
302302
* },function (error) {
303303
* // error function
304304
* })
@@ -370,7 +370,7 @@ export default class Query extends Entry {
370370
}
371371

372372
/**
373-
* @method where()
373+
* @method where
374374
* @description Retrieve entries in which a specific field satisfies the value provided
375375
* @param {String} key - uid of the field
376376
* @param {*} value - value used to match or compare
@@ -477,19 +477,7 @@ export default class Query extends Entry {
477477
return this;
478478
}
479479

480-
/**
481-
* @method AddParam
482-
* @description Retrieves entries based on the query provided
483-
* @example blogQuery.addParam('include_count', 'true')
484-
* @example let blogQuery = Stack().ContentType('example').Query();
485-
* let data = blogQuery.addParam('include_count', 'true').find()
486-
* data.then(function(result) {
487-
* // ‘result’ contains the count of object present in array[1] position.
488-
* },function (error) {
489-
* // error function
490-
* })
491-
* @returns {Query}
492-
*/
480+
493481
addParam(key, value) {
494482
if (key && value && typeof key === 'string' && typeof value === 'string') {
495483
this._query[key] = value;

0 commit comments

Comments
 (0)