@@ -29,7 +29,7 @@ export class Entry {
2929 * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
3030 * const result = await stack.contentType(contentType_uid).entry(entry_uid).includeFallback().fetch();
3131 */
32- includeFallback ( ) : Entry {
32+ includeFallback ( ) : this {
3333 this . _queryParams . include_fallback = 'true' ;
3434
3535 return this ;
@@ -46,7 +46,7 @@ export class Entry {
4646 * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
4747 * const result = await stack.contentType('abc').entry('entry_uid').variants('xyz').fetch();
4848 */
49- variants ( variants : string | string [ ] ) : Entry {
49+ variants ( variants : string | string [ ] ) : this {
5050 if ( Array . isArray ( variants ) && variants . length > 0 ) {
5151 this . _variants = variants . join ( ',' ) ;
5252 } else if ( typeof variants == 'string' && variants . length > 0 ) {
@@ -67,7 +67,7 @@ export class Entry {
6767 * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
6868 * const result = await stack.contentType(contentType_uid).entry(entry_uid).includeMetadata().fetch();
6969 */
70- includeMetadata ( ) : Entry {
70+ includeMetadata ( ) : this {
7171 this . _queryParams . include_metadata = 'true' ;
7272
7373 return this ;
@@ -84,7 +84,7 @@ export class Entry {
8484 * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
8585 * const result = await stack.contentType(contentType_uid).entry(entry_uid).includeEmbeddedItems().fetch();
8686 */
87- includeEmbeddedItems ( ) : Entry {
87+ includeEmbeddedItems ( ) : this {
8888 this . _queryParams [ 'include_embedded_items[]' ] = 'BASE' ;
8989
9090 return this ;
@@ -103,7 +103,7 @@ export class Entry {
103103 * @param {string } referenceFieldUid - UID of the reference field to include.
104104 * @returns {Entry } - Returns the Entry instance for chaining.
105105 */
106- includeReference ( ...referenceFieldUid : ( string | string [ ] ) [ ] ) : Entry {
106+ includeReference ( ...referenceFieldUid : ( string | string [ ] ) [ ] ) : this {
107107 if ( referenceFieldUid . length ) {
108108 referenceFieldUid . forEach ( value => {
109109 if ( ! Array . isArray ( this . _queryParams [ 'include[]' ] ) ) {
@@ -128,7 +128,7 @@ export class Entry {
128128 * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
129129 * const result = await stack.contentType(contentType_uid).entry(entry_uid).includeContentType().fetch();
130130 */
131- includeContentType ( ) : Entry {
131+ includeContentType ( ) : this {
132132 this . _queryParams . include_content_type = 'true' ;
133133
134134 return this ;
@@ -145,7 +145,7 @@ export class Entry {
145145 * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
146146 * const result = await stack.contentType(contentType_uid).entry(entry_uid).includeBranch().fetch();
147147 */
148- includeBranch ( ) : Entry {
148+ includeBranch ( ) : this {
149149 this . _queryParams . include_branch = 'true' ;
150150
151151 return this ;
@@ -162,7 +162,7 @@ export class Entry {
162162 * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
163163 * const result = await stack.assetQuery().locale('en-us').fetch();
164164 */
165- locale ( locale : string ) : Entry {
165+ locale ( locale : string ) : this {
166166 this . _queryParams . locale = locale ;
167167
168168 return this ;
@@ -195,7 +195,7 @@ export class Entry {
195195 return response ;
196196 }
197197
198- /**
198+ /**
199199 * @method addParams
200200 * @memberof Entry
201201 * @description Adds a query parameter to the query.
@@ -207,9 +207,62 @@ export class Entry {
207207 *
208208 * @returns {Entry }
209209 */
210- addParams ( paramObj : { [ key : string ] : string | number | string [ ] } ) : Entry {
210+ addParams ( paramObj : { [ key : string ] : string | number | string [ ] } ) : this {
211211 this . _queryParams = { ...this . _queryParams , ...paramObj } ;
212212
213213 return this ;
214214 }
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+ }
215268}
0 commit comments