@@ -29,7 +29,7 @@ export class Entry {
29
29
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
30
30
* const result = await stack.contentType(contentType_uid).entry(entry_uid).includeFallback().fetch();
31
31
*/
32
- includeFallback ( ) : Entry {
32
+ includeFallback ( ) : this {
33
33
this . _queryParams . include_fallback = 'true' ;
34
34
35
35
return this ;
@@ -46,7 +46,7 @@ export class Entry {
46
46
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
47
47
* const result = await stack.contentType('abc').entry('entry_uid').variants('xyz').fetch();
48
48
*/
49
- variants ( variants : string | string [ ] ) : Entry {
49
+ variants ( variants : string | string [ ] ) : this {
50
50
if ( Array . isArray ( variants ) && variants . length > 0 ) {
51
51
this . _variants = variants . join ( ',' ) ;
52
52
} else if ( typeof variants == 'string' && variants . length > 0 ) {
@@ -67,7 +67,7 @@ export class Entry {
67
67
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
68
68
* const result = await stack.contentType(contentType_uid).entry(entry_uid).includeMetadata().fetch();
69
69
*/
70
- includeMetadata ( ) : Entry {
70
+ includeMetadata ( ) : this {
71
71
this . _queryParams . include_metadata = 'true' ;
72
72
73
73
return this ;
@@ -84,7 +84,7 @@ export class Entry {
84
84
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
85
85
* const result = await stack.contentType(contentType_uid).entry(entry_uid).includeEmbeddedItems().fetch();
86
86
*/
87
- includeEmbeddedItems ( ) : Entry {
87
+ includeEmbeddedItems ( ) : this {
88
88
this . _queryParams [ 'include_embedded_items[]' ] = 'BASE' ;
89
89
90
90
return this ;
@@ -103,7 +103,7 @@ export class Entry {
103
103
* @param {string } referenceFieldUid - UID of the reference field to include.
104
104
* @returns {Entry } - Returns the Entry instance for chaining.
105
105
*/
106
- includeReference ( ...referenceFieldUid : ( string | string [ ] ) [ ] ) : Entry {
106
+ includeReference ( ...referenceFieldUid : ( string | string [ ] ) [ ] ) : this {
107
107
if ( referenceFieldUid . length ) {
108
108
referenceFieldUid . forEach ( value => {
109
109
if ( ! Array . isArray ( this . _queryParams [ 'include[]' ] ) ) {
@@ -128,7 +128,7 @@ export class Entry {
128
128
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
129
129
* const result = await stack.contentType(contentType_uid).entry(entry_uid).includeContentType().fetch();
130
130
*/
131
- includeContentType ( ) : Entry {
131
+ includeContentType ( ) : this {
132
132
this . _queryParams . include_content_type = 'true' ;
133
133
134
134
return this ;
@@ -145,7 +145,7 @@ export class Entry {
145
145
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
146
146
* const result = await stack.contentType(contentType_uid).entry(entry_uid).includeBranch().fetch();
147
147
*/
148
- includeBranch ( ) : Entry {
148
+ includeBranch ( ) : this {
149
149
this . _queryParams . include_branch = 'true' ;
150
150
151
151
return this ;
@@ -162,7 +162,7 @@ export class Entry {
162
162
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
163
163
* const result = await stack.assetQuery().locale('en-us').fetch();
164
164
*/
165
- locale ( locale : string ) : Entry {
165
+ locale ( locale : string ) : this {
166
166
this . _queryParams . locale = locale ;
167
167
168
168
return this ;
@@ -195,7 +195,7 @@ export class Entry {
195
195
return response ;
196
196
}
197
197
198
- /**
198
+ /**
199
199
* @method addParams
200
200
* @memberof Entry
201
201
* @description Adds a query parameter to the query.
@@ -207,9 +207,62 @@ export class Entry {
207
207
*
208
208
* @returns {Entry }
209
209
*/
210
- addParams ( paramObj : { [ key : string ] : string | number | string [ ] } ) : Entry {
210
+ addParams ( paramObj : { [ key : string ] : string | number | string [ ] } ) : this {
211
211
this . _queryParams = { ...this . _queryParams , ...paramObj } ;
212
212
213
213
return this ;
214
214
}
215
+
216
+ /**
217
+ * @method except
218
+ * @memberof Entry
219
+ * @description Excludes specific field/fields of an entry
220
+ * @example
221
+ * import contentstack from '@contentstack/delivery-sdk'
222
+ *
223
+ * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
224
+ * const result = await stack.contentType("contentTypeUid").entry().except("fieldUID").find()
225
+ *
226
+ * @param {string } fieldUid - field uid to exclude
227
+ * @returns {Entry } - returns Entry object for chaining method calls
228
+ */
229
+ except ( fieldUid : string | string [ ] ) : this {
230
+ if ( Array . isArray ( fieldUid ) ) {
231
+ let i = 0 ;
232
+ for ( const uid of fieldUid ) {
233
+ this . _queryParams [ `except[BASE][${ i } ]` ] = uid ;
234
+ i ++ ;
235
+ }
236
+ } else {
237
+ this . _queryParams [ "except[BASE][]" ] = fieldUid ;
238
+ }
239
+
240
+ return this ;
241
+ }
242
+
243
+ /**
244
+ * @method only
245
+ * @memberof Entry
246
+ * @description Selects specific field/fields of an entry
247
+ * @example
248
+ * import contentstack from '@contentstack/delivery-sdk'
249
+ *
250
+ * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
251
+ * const result = await stack.contentType("contentTypeUid").entry().only("fieldUID").find()
252
+ *
253
+ * @param {string } fieldUid - field uid to select
254
+ * @returns {Entry } - returns Entry object for chaining method calls
255
+ */
256
+ only ( fieldUid : string | string [ ] ) : this {
257
+ if ( Array . isArray ( fieldUid ) ) {
258
+ let i = 0 ;
259
+ for ( const uid of fieldUid ) {
260
+ this . _queryParams [ `only[BASE][${ i } ]` ] = uid ;
261
+ i ++ ;
262
+ }
263
+ } else {
264
+ this . _queryParams [ "only[BASE][]" ] = fieldUid ;
265
+ }
266
+ return this ;
267
+ }
215
268
}
0 commit comments