1
1
import { AxiosInstance , getData } from '@contentstack/core' ;
2
- import { EntryQueryable } from './entry-queryable' ;
3
2
import { Query } from './query' ;
3
+ import { BaseQuery } from './base-query' ;
4
4
5
- export class Entries extends EntryQueryable {
5
+ export class Entries extends BaseQuery {
6
6
private _contentTypeUid : string ;
7
7
8
8
constructor ( client : AxiosInstance , contentTypeUid : string ) {
@@ -14,35 +14,62 @@ export class Entries extends EntryQueryable {
14
14
}
15
15
16
16
/**
17
- * @method includeFallback
17
+ * @method except
18
18
* @memberof Entries
19
- * @description When an entry is not published in a specific language, content can be fetched from its fallback language
19
+ * @description Excludes specific field/fields of an entry
20
+ * @example
21
+ * import contentstack from '@contentstack/delivery-sdk'
22
+ *
23
+ * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
24
+ * const result = await stack.contentType("contentTypeUid").entry().except("fieldUID").find()
25
+ *
26
+ * @param {string } fieldUid - field uid to exclude
27
+ * @returns {Entries } - returns Entries object for chaining method calls
28
+ */
29
+ except ( fieldUid : string | string [ ] ) : this {
30
+ if ( Array . isArray ( fieldUid ) ) {
31
+ let i = 0 ;
32
+ for ( const uid of fieldUid ) {
33
+ this . _queryParams [ `except[BASE][${ i } ]` ] = uid ;
34
+ i ++ ;
35
+ }
36
+ } else {
37
+ this . _queryParams [ "except[BASE][]" ] = fieldUid ;
38
+ }
39
+
40
+ return this ;
41
+ }
42
+
43
+ /**
44
+ * @method includeBranch
45
+ * @memberof Entries
46
+ * @description Includes the branch in result
20
47
* @returns {Entries }
21
48
* @example
22
49
* import contentstack from '@contentstack/delivery-sdk'
23
50
*
24
51
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
25
- * const result = await stack.contentType(contentType_uid).entry().includeFallback ().find();
52
+ * const result = await stack.contentType(contentType_uid).entry().includeBranch ().find();
26
53
*/
27
- includeFallback ( ) : Entries {
28
- this . _queryParams . include_fallback = 'true' ;
54
+ includeBranch ( ) : Entries {
55
+ this . _queryParams . include_branch = 'true' ;
29
56
30
57
return this ;
31
58
}
32
59
33
60
/**
34
- * @method includeMetadata
61
+ * @method includeContentType
35
62
* @memberof Entries
36
- * @description Include the metadata for getting metadata content for the entry.
63
+ * @description IInclude the details of the content type along with the entries details
37
64
* @returns {Entries }
38
65
* @example
39
66
* import contentstack from '@contentstack/delivery-sdk'
40
67
*
41
68
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
42
- * const result = await stack.contentType(contentType_uid).entry().includeMetadata ().find ();
69
+ * const result = await stack.contentType(contentType_uid).entry().includeContentType ().fetch ();
43
70
*/
44
- includeMetadata ( ) : Entries {
45
- this . _queryParams . include_metadata = 'true' ;
71
+ includeContentType ( ) : Entries {
72
+ this . _queryParams . include_content_type = 'true' ;
46
73
47
74
return this ;
48
75
}
@@ -65,35 +92,35 @@ export class Entries extends EntryQueryable {
65
92
}
66
93
67
94
/**
68
- * @method includeContentType
95
+ * @method includeFallback
69
96
* @memberof Entries
70
- * @description IInclude the details of the content type along with the entries details
97
+ * @description When an entry is not published in a specific language, content can be fetched from its fallback language
71
98
* @returns {Entries }
72
99
* @example
73
100
* import contentstack from '@contentstack/delivery-sdk'
74
101
*
75
102
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
76
- * const result = await stack.contentType(contentType_uid).entry().includeContentType ().fetch ();
103
+ * const result = await stack.contentType(contentType_uid).entry().includeFallback ().find ();
77
104
*/
78
- includeContentType ( ) : Entries {
79
- this . _queryParams . include_content_type = 'true' ;
105
+ includeFallback ( ) : Entries {
106
+ this . _queryParams . include_fallback = 'true' ;
80
107
81
108
return this ;
82
109
}
83
110
84
111
/**
85
- * @method includeBranch
112
+ * @method includeMetadata
86
113
* @memberof Entries
87
- * @description Includes the branch in result
114
+ * @description Include the metadata for getting metadata content for the entry.
88
115
* @returns {Entries }
89
116
* @example
90
117
* import contentstack from '@contentstack/delivery-sdk'
91
118
*
92
119
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
93
- * const result = await stack.contentType(contentType_uid).entry().includeBranch ().find();
120
+ * const result = await stack.contentType(contentType_uid).entry().includeMetadata ().find();
94
121
*/
95
- includeBranch ( ) : Entries {
96
- this . _queryParams . include_branch = 'true' ;
122
+ includeMetadata ( ) : Entries {
123
+ this . _queryParams . include_metadata = 'true' ;
97
124
98
125
return this ;
99
126
}
@@ -177,6 +204,32 @@ export class Entries extends EntryQueryable {
177
204
return this ;
178
205
}
179
206
207
+ /**
208
+ * @method only
209
+ * @memberof Entries
210
+ * @description Selects specific field/fields of an entry
211
+ * @example
212
+ * import contentstack from '@contentstack/delivery-sdk'
213
+ *
214
+ * const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
215
+ * const result = await stack.contentType("contentTypeUid").entry().only("fieldUID").find()
216
+ *
217
+ * @param {string } fieldUid - field uid to select
218
+ * @returns {Entries } - returns Entries object for chaining method calls
219
+ */
220
+ only ( fieldUid : string | string [ ] ) : this {
221
+ if ( Array . isArray ( fieldUid ) ) {
222
+ let i = 0 ;
223
+ for ( const uid of fieldUid ) {
224
+ this . _queryParams [ `only[BASE][${ i } ]` ] = uid ;
225
+ i ++ ;
226
+ }
227
+ } else {
228
+ this . _queryParams [ "only[BASE][]" ] = fieldUid ;
229
+ }
230
+ return this ;
231
+ }
232
+
180
233
/**
181
234
* @method query
182
235
* @memberof Entries
0 commit comments