@contentstack/datasync-mongodb-sdk 1.0.9-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/codeql-analysis.yml +68 -0
- package/.github/workflows/jira.yml +33 -0
- package/.github/workflows/release.yml +77 -0
- package/.github/workflows/sast-scan.yml +11 -0
- package/.github/workflows/sca-scan.yml +15 -0
- package/.talismanrc +4 -0
- package/CODEOWNERS +1 -0
- package/LICENCE +21 -0
- package/README.md +191 -0
- package/SECURITY.md +27 -0
- package/contentstack-datasync-mongodb-sdk-1.0.9-beta.1.tgz +0 -0
- package/dist/config.js +47 -0
- package/dist/index.js +42 -0
- package/dist/stack.js +2272 -0
- package/dist/util.js +86 -0
- package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Bold-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Light-webfont.svg +1831 -0
- package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.svg +1831 -0
- package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docs/global.html +7520 -0
- package/docs/global.html#Stack +1070 -0
- package/docs/index.html +291 -0
- package/docs/index.js.html +92 -0
- package/docs/scripts/linenumber.js +25 -0
- package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/docs/scripts/prettify/lang-css.js +2 -0
- package/docs/stack.js.html +2244 -0
- package/docs/styles/jsdoc-default.css +358 -0
- package/docs/styles/prettify-jsdoc.css +111 -0
- package/docs/styles/prettify-tomorrow.css +132 -0
- package/example/index.js +56 -0
- package/package.json +59 -0
- package/test/comparison-operators.ts +257 -0
- package/test/conditional-operators.ts +106 -0
- package/test/config.ts +12 -0
- package/test/core.ts +333 -0
- package/test/count.ts +98 -0
- package/test/data/assets.ts +35 -0
- package/test/data/author.ts +168 -0
- package/test/data/blog.ts +138 -0
- package/test/data/category.ts +20 -0
- package/test/data/content_types.ts +164 -0
- package/test/data/products.ts +64 -0
- package/test/expressions.ts +108 -0
- package/test/include-exclude.ts +176 -0
- package/test/logical-operators.ts +140 -0
- package/test/projections.ts +109 -0
- package/test/queries.ts +143 -0
- package/test/references.ts +162 -0
- package/test/skip-limit.ts +150 -0
- package/test/sorting.ts +177 -0
- package/tslint.json +45 -0
- package/typings/config.d.ts +42 -0
- package/typings/index.d.ts +36 -0
- package/typings/stack.d.ts +1097 -0
- package/typings/util.d.ts +28 -0
|
@@ -0,0 +1,1097 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Contentstack DataSync Mongodb SDK
|
|
3
|
+
* Copyright (c) 2019 Contentstack LLC
|
|
4
|
+
* MIT Licensed
|
|
5
|
+
*/
|
|
6
|
+
import { Db } from 'mongodb';
|
|
7
|
+
/**
|
|
8
|
+
* @class Stack
|
|
9
|
+
* @descriptionExpose SDK query methods on Stack
|
|
10
|
+
* @constructor
|
|
11
|
+
* @descriptionProvides a range of connection/disconnect, filters and projections on mongodb
|
|
12
|
+
* @returns {Stack} Returns an instance of `Stack`
|
|
13
|
+
*/
|
|
14
|
+
export declare class Stack {
|
|
15
|
+
private q;
|
|
16
|
+
private readonly collectionNames;
|
|
17
|
+
private readonly config;
|
|
18
|
+
private readonly contentStore;
|
|
19
|
+
private readonly types;
|
|
20
|
+
private client;
|
|
21
|
+
private collection;
|
|
22
|
+
private internal;
|
|
23
|
+
private db;
|
|
24
|
+
constructor(stackConfig: any, existingDB?: any);
|
|
25
|
+
/**
|
|
26
|
+
* @public
|
|
27
|
+
* @method ascending
|
|
28
|
+
* @summary Sorts the documents based on the 'sort' key
|
|
29
|
+
* @description
|
|
30
|
+
* The sort function requires that the entire sort be able to complete within 32 megabytes.
|
|
31
|
+
* When the sort option consumes more than 32 megabytes, MongoDB will return an error.
|
|
32
|
+
* @param {string} field The field to sort in ascending order
|
|
33
|
+
* @example
|
|
34
|
+
* Stack
|
|
35
|
+
* .contentType('')
|
|
36
|
+
* .entries()
|
|
37
|
+
* .ascending()
|
|
38
|
+
* .find()
|
|
39
|
+
* .then((result) => {
|
|
40
|
+
* // result sorted in ascending manner with respect to 'published_at' field (by default)
|
|
41
|
+
* })
|
|
42
|
+
* .catch((error) => {
|
|
43
|
+
* // handle query errors
|
|
44
|
+
* })
|
|
45
|
+
*
|
|
46
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
47
|
+
*/
|
|
48
|
+
ascending(field: any): this;
|
|
49
|
+
/**
|
|
50
|
+
* @public
|
|
51
|
+
* @method descending
|
|
52
|
+
* @summary Sorts the documents based on the 'sort' key
|
|
53
|
+
* @description
|
|
54
|
+
* The sort function requires that the entire sort be able to complete within 32 megabytes.
|
|
55
|
+
* When the sort option consumes more than 32 megabytes, MongoDB will return an error.
|
|
56
|
+
*
|
|
57
|
+
* @param {string} field The field to sort in descending order
|
|
58
|
+
* @example
|
|
59
|
+
* Stack
|
|
60
|
+
* .contentType('')
|
|
61
|
+
* .entries()
|
|
62
|
+
* .descending('title')
|
|
63
|
+
* .find()
|
|
64
|
+
* .then((result) => {
|
|
65
|
+
* // result sorted in descending manner with respect to 'title' field
|
|
66
|
+
* })
|
|
67
|
+
* .catch((error) => {
|
|
68
|
+
* // handle query errors
|
|
69
|
+
* })
|
|
70
|
+
*
|
|
71
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
72
|
+
*/
|
|
73
|
+
descending(field: any): this;
|
|
74
|
+
/**
|
|
75
|
+
* @public
|
|
76
|
+
* @method connect
|
|
77
|
+
* @summary
|
|
78
|
+
* Establish connection to mongodb
|
|
79
|
+
*
|
|
80
|
+
* @param {object} overrides Config overrides/mongodb specific config
|
|
81
|
+
* @example
|
|
82
|
+
* Stack
|
|
83
|
+
* .connect({overrides})
|
|
84
|
+
* .then((result) => {
|
|
85
|
+
* // mongodb connection object
|
|
86
|
+
* // indexes will be created on the collection in the background if provided in config
|
|
87
|
+
* })
|
|
88
|
+
* .catch((error) => {
|
|
89
|
+
* // handle query errors
|
|
90
|
+
* })
|
|
91
|
+
*
|
|
92
|
+
* @returns {object} Mongodb 'db' instance
|
|
93
|
+
*/
|
|
94
|
+
connect(overrides?: {}): Promise<Db>;
|
|
95
|
+
/**
|
|
96
|
+
* @public
|
|
97
|
+
* @method close
|
|
98
|
+
* @summary Closes connection with mongodb
|
|
99
|
+
*/
|
|
100
|
+
close(): void;
|
|
101
|
+
/**
|
|
102
|
+
* @method language
|
|
103
|
+
* @description
|
|
104
|
+
* Locale to query on
|
|
105
|
+
*
|
|
106
|
+
* @param {string} code Query locale's code
|
|
107
|
+
* @example
|
|
108
|
+
* Stack
|
|
109
|
+
* .contentType('')
|
|
110
|
+
* .entries()
|
|
111
|
+
* .language('es-es')
|
|
112
|
+
* .find()
|
|
113
|
+
* .then((result) => {
|
|
114
|
+
* // results in entries fetched from 'es-es' locale
|
|
115
|
+
* // if not provided, defaults to the 1st locale provided in the 'locales' key, provided in config
|
|
116
|
+
* })
|
|
117
|
+
* .catch((error) => {
|
|
118
|
+
* // handle query errors
|
|
119
|
+
* })
|
|
120
|
+
*
|
|
121
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
122
|
+
*/
|
|
123
|
+
language(code: any): this;
|
|
124
|
+
/**
|
|
125
|
+
* @public
|
|
126
|
+
* @method and
|
|
127
|
+
* @summary Logical AND query wrapper
|
|
128
|
+
* @descriptionAccepts 2 queries and returns only those documents, that satisfy both the query conditions
|
|
129
|
+
* @param {object} queries Query filter
|
|
130
|
+
* @example
|
|
131
|
+
* Stack
|
|
132
|
+
* .contentType('')
|
|
133
|
+
* .entries()
|
|
134
|
+
* .and([
|
|
135
|
+
* {
|
|
136
|
+
* title: 'John'
|
|
137
|
+
* },
|
|
138
|
+
* {
|
|
139
|
+
* age: 30
|
|
140
|
+
* }
|
|
141
|
+
* ])
|
|
142
|
+
* .find()
|
|
143
|
+
* .then((result) => {
|
|
144
|
+
* // filtered entries, where { title: 'John', age: 30 }
|
|
145
|
+
* })
|
|
146
|
+
* .catch((error) => {
|
|
147
|
+
* // handle query errors
|
|
148
|
+
* })
|
|
149
|
+
*
|
|
150
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
151
|
+
*/
|
|
152
|
+
and(queries: any): this;
|
|
153
|
+
/**
|
|
154
|
+
* @public
|
|
155
|
+
* @method or
|
|
156
|
+
* @summary Logical OR query wrapper
|
|
157
|
+
* @descriptionAccepts 2 queries and returns only those documents, that satisfy either of the query conditions
|
|
158
|
+
* @param {object} queries Query filter
|
|
159
|
+
* @example
|
|
160
|
+
* Stack
|
|
161
|
+
* .contentType('')
|
|
162
|
+
* .entries()
|
|
163
|
+
* .or([
|
|
164
|
+
* {
|
|
165
|
+
* title: 'John'
|
|
166
|
+
* },
|
|
167
|
+
* {
|
|
168
|
+
* title: 'Jane'
|
|
169
|
+
* }
|
|
170
|
+
* ])
|
|
171
|
+
* .find()
|
|
172
|
+
* .then((result) => {
|
|
173
|
+
* // filtered entries, where { title: 'John' } OR { title: 'Jane' }
|
|
174
|
+
* })
|
|
175
|
+
* .catch((error) => {
|
|
176
|
+
* // handle query errors
|
|
177
|
+
* })
|
|
178
|
+
*
|
|
179
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
180
|
+
*/
|
|
181
|
+
or(queries: any): this;
|
|
182
|
+
/**
|
|
183
|
+
* @public
|
|
184
|
+
* @method lessThan
|
|
185
|
+
* @summary Comparison $lt query wrapper
|
|
186
|
+
* @description
|
|
187
|
+
* Compares the field/key provided against the provided value.
|
|
188
|
+
* Only documents that have lower value than the one provided are returned.
|
|
189
|
+
* Check https://docs.mongodb.com/manual/reference/operator/query/lt/
|
|
190
|
+
* and https://docs.mongodb.com/manual/reference/method/db.collection.find/#type-bracketing for more info
|
|
191
|
+
* @param {string} key Field to compare against
|
|
192
|
+
* @param {*} value Value to compare with
|
|
193
|
+
* @example
|
|
194
|
+
* Stack
|
|
195
|
+
* .contentType('')
|
|
196
|
+
* .entries()
|
|
197
|
+
* .lessThan('age', 18)
|
|
198
|
+
* .find()
|
|
199
|
+
* .then((result) => {
|
|
200
|
+
* // filtered entries, where { age < 18 }
|
|
201
|
+
* })
|
|
202
|
+
* .catch((error) => {
|
|
203
|
+
* // handle query errors
|
|
204
|
+
* })
|
|
205
|
+
*
|
|
206
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
207
|
+
*/
|
|
208
|
+
lessThan(key: any, value: any): this;
|
|
209
|
+
/**
|
|
210
|
+
* @public
|
|
211
|
+
* @method lessThanOrEqualTo
|
|
212
|
+
* @summary Comparison $lte query wrapper
|
|
213
|
+
* @description
|
|
214
|
+
* Compares the field/key provided against the provided value.
|
|
215
|
+
* Only documents that have lower or equal value than the one provided are returned.
|
|
216
|
+
* Check https://docs.mongodb.com/manual/reference/operator/query/lte/
|
|
217
|
+
* and https://docs.mongodb.com/manual/reference/method/db.collection.find/#type-bracketing for more info
|
|
218
|
+
* @param {string} key Field to compare against
|
|
219
|
+
* @param {*} value Value to compare with
|
|
220
|
+
* @example
|
|
221
|
+
* Stack
|
|
222
|
+
* .contentType('')
|
|
223
|
+
* .entries()
|
|
224
|
+
* .lessThanOrEqualTo('age', 18)
|
|
225
|
+
* .find()
|
|
226
|
+
* .then((result) => {
|
|
227
|
+
* // filtered entries, where { age <= 18 }
|
|
228
|
+
* })
|
|
229
|
+
* .catch((error) => {
|
|
230
|
+
* // handle query errors
|
|
231
|
+
* })
|
|
232
|
+
*
|
|
233
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
234
|
+
*/
|
|
235
|
+
lessThanOrEqualTo(key: any, value: any): this;
|
|
236
|
+
/**
|
|
237
|
+
* @public
|
|
238
|
+
* @method greaterThan
|
|
239
|
+
* @summary Comparison $gt query wrapper
|
|
240
|
+
* @description
|
|
241
|
+
* Compares the field/key provided against the provided value.
|
|
242
|
+
* Only documents that have greater value than the one provided are returned.
|
|
243
|
+
* Check {@link https://docs.mongodb.com/manual/reference/operator/query/gt/ }
|
|
244
|
+
* and https://docs.mongodb.com/manual/reference/method/db.collection.find/#type-bracketing for more info
|
|
245
|
+
* @param {string} key Field to compare against
|
|
246
|
+
* @param {*} value Value to compare with
|
|
247
|
+
* @example
|
|
248
|
+
* Stack
|
|
249
|
+
* .contentType('')
|
|
250
|
+
* .entries()
|
|
251
|
+
* .greaterThan('age', 60)
|
|
252
|
+
* .find()
|
|
253
|
+
* .then((result) => {
|
|
254
|
+
* // filtered entries, where { age > 60 }
|
|
255
|
+
* })
|
|
256
|
+
* .catch((error) => {
|
|
257
|
+
* // handle query errors
|
|
258
|
+
* })
|
|
259
|
+
*
|
|
260
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
261
|
+
*/
|
|
262
|
+
greaterThan(key: any, value: any): this;
|
|
263
|
+
/**
|
|
264
|
+
* @public
|
|
265
|
+
* @method greaterThanOrEqualTo
|
|
266
|
+
* @summary Comparison $gte query wrapper
|
|
267
|
+
* @description
|
|
268
|
+
* Compares the field/key provided against the provided value.
|
|
269
|
+
* Only documents that have greater than or equal value than the one provided are returned.
|
|
270
|
+
* Check https://docs.mongodb.com/manual/reference/operator/query/gte/ and
|
|
271
|
+
* https://docs.mongodb.com/manual/reference/method/db.collection.find/#type-bracketing for more info
|
|
272
|
+
* @param {string} key - Field to compare against
|
|
273
|
+
* @param {*} value - Value to compare with
|
|
274
|
+
* @example
|
|
275
|
+
* Stack
|
|
276
|
+
* .contentType('')
|
|
277
|
+
* .entries()
|
|
278
|
+
* .greaterThanOrEqualTo('age', 60)
|
|
279
|
+
* .find()
|
|
280
|
+
* .then((result) => {
|
|
281
|
+
* // filtered entries, where { age >= 60 }
|
|
282
|
+
* })
|
|
283
|
+
* .catch((error) => {
|
|
284
|
+
* // handle query errors
|
|
285
|
+
* })
|
|
286
|
+
*
|
|
287
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
288
|
+
*/
|
|
289
|
+
greaterThanOrEqualTo(key: any, value: any): this;
|
|
290
|
+
/**
|
|
291
|
+
* @public
|
|
292
|
+
* @method notEqualTo
|
|
293
|
+
* @summary Comparison $ne query wrapper
|
|
294
|
+
* @description
|
|
295
|
+
* Compares the field/key provided against the provided value.
|
|
296
|
+
* Only documents that have value not equals than the one provided are returned.
|
|
297
|
+
*
|
|
298
|
+
* Check mongodb query here: {@link https://docs.mongodb.com/manual/reference/operator/query/ne/}.
|
|
299
|
+
*
|
|
300
|
+
* Res: {@link https://docs.mongodb.com/manual/reference/method/db.collection.find/#type-bracketing}.
|
|
301
|
+
*
|
|
302
|
+
* Comparison ordering
|
|
303
|
+
* {@link https://docs.mongodb.com/manual/reference/bson-type-comparison-order/#bson-types-comparison-order}
|
|
304
|
+
* @param {string} key Field to compare against
|
|
305
|
+
* @param {*} value Value to compare with
|
|
306
|
+
* @example
|
|
307
|
+
* Stack
|
|
308
|
+
* .contentType('')
|
|
309
|
+
* .entries()
|
|
310
|
+
* .notEqualTo('age', 25)
|
|
311
|
+
* .find()
|
|
312
|
+
* .then((result) => {
|
|
313
|
+
* // filtered entries, where { age != 25 }
|
|
314
|
+
* })
|
|
315
|
+
* .catch((error) => {
|
|
316
|
+
* // handle query errors
|
|
317
|
+
* })
|
|
318
|
+
*
|
|
319
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
320
|
+
*/
|
|
321
|
+
notEqualTo(key: any, value: any): this;
|
|
322
|
+
/**
|
|
323
|
+
* @public
|
|
324
|
+
* @method containedIn
|
|
325
|
+
* @summary Comparison $in query wrapper
|
|
326
|
+
* @description
|
|
327
|
+
* Compares the field/key provided against the provided value.
|
|
328
|
+
* Only documents that have value contained in the field/key provided are returned.
|
|
329
|
+
*
|
|
330
|
+
* Check mongodb query here: {@link https://docs.mongodb.com/manual/reference/operator/query/in/}.
|
|
331
|
+
*
|
|
332
|
+
* Res: {@link https://docs.mongodb.com/manual/reference/method/db.collection.find/#type-bracketing}.
|
|
333
|
+
*
|
|
334
|
+
* Comparison ordering
|
|
335
|
+
* {@link https://docs.mongodb.com/manual/reference/bson-type-comparison-order/#bson-types-comparison-order}
|
|
336
|
+
* @param {string} key Field to compare against
|
|
337
|
+
* @param {*} value Value to compare with
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* Stack
|
|
341
|
+
* .contentType('')
|
|
342
|
+
* .entries()
|
|
343
|
+
* .containedIn('emails', 'john.doe@some.com')
|
|
344
|
+
* .find()
|
|
345
|
+
* .then((result) => {
|
|
346
|
+
* // filtered entries, where 'john.doe@some.com' exists in 'emails' field (array)
|
|
347
|
+
* })
|
|
348
|
+
* .catch((error) => {
|
|
349
|
+
* // handle query errors
|
|
350
|
+
* })
|
|
351
|
+
*
|
|
352
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
353
|
+
*/
|
|
354
|
+
containedIn(key: any, value: any): this;
|
|
355
|
+
/**
|
|
356
|
+
* @public
|
|
357
|
+
* @method notContainedIn
|
|
358
|
+
* @summary Comparison $nin query wrapper
|
|
359
|
+
* @description
|
|
360
|
+
* Compares the field/key provided against the provided value.
|
|
361
|
+
* Only documents that have value not contained in the field/key provided are returned.
|
|
362
|
+
*
|
|
363
|
+
* Check mongodb query here: {@link https://docs.mongodb.com/manual/reference/operator/query/nin/}.
|
|
364
|
+
*
|
|
365
|
+
* Res: {@link https://docs.mongodb.com/manual/reference/method/db.collection.find/#type-bracketing}.
|
|
366
|
+
*
|
|
367
|
+
* Comparison ordering
|
|
368
|
+
* {@link https://docs.mongodb.com/manual/reference/bson-type-comparison-order/#bson-types-comparison-order}
|
|
369
|
+
* @param {string} key Field to compare against
|
|
370
|
+
* @param {*} value Value to compare with
|
|
371
|
+
*
|
|
372
|
+
* @example
|
|
373
|
+
* Stack
|
|
374
|
+
* .contentType('')
|
|
375
|
+
* .entries()
|
|
376
|
+
* .notContainedIn('emails', 'john.doe@some.com')
|
|
377
|
+
* .find()
|
|
378
|
+
* .then((result) => {
|
|
379
|
+
* // filtered entries, where 'john.doe@some.com' does not exist in 'emails' field (array)
|
|
380
|
+
* })
|
|
381
|
+
* .catch((error) => {
|
|
382
|
+
* // handle query errors
|
|
383
|
+
* })
|
|
384
|
+
*
|
|
385
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
386
|
+
*/
|
|
387
|
+
notContainedIn(key: any, value: any): this;
|
|
388
|
+
/**
|
|
389
|
+
* @public
|
|
390
|
+
* @method exists
|
|
391
|
+
* @summary Element $exists query wrapper, checks if a field exists
|
|
392
|
+
* @description
|
|
393
|
+
* Compares the field / key provided against the provided value.Only documents that have the field /
|
|
394
|
+
* key specified are returned.
|
|
395
|
+
*
|
|
396
|
+
* Check mongodb query here: {@link https://docs.mongodb.com/manual/reference/operator/query/exists/}.
|
|
397
|
+
*
|
|
398
|
+
* Res: {@link https://docs.mongodb.com/manual/reference/method/db.collection.find/#type-bracketing}.
|
|
399
|
+
*
|
|
400
|
+
* Comparison ordering{
|
|
401
|
+
* @link https: //docs.mongodb.com/manual/reference/bson-type-comparison-order/#bson-types-comparison-order}
|
|
402
|
+
* @param {string} key Field to compare against
|
|
403
|
+
* @param {*} value Value to compare with
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* Stack
|
|
407
|
+
* .contentType('')
|
|
408
|
+
* .entries()
|
|
409
|
+
* .exists('emails')
|
|
410
|
+
* .find()
|
|
411
|
+
* .then((result) => {
|
|
412
|
+
* // filtered entries, where 'emails' property exists
|
|
413
|
+
* })
|
|
414
|
+
* .catch((error) => {
|
|
415
|
+
* // handle query errors
|
|
416
|
+
* })
|
|
417
|
+
*
|
|
418
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
419
|
+
*/
|
|
420
|
+
exists(key: any): this;
|
|
421
|
+
/**
|
|
422
|
+
* @public
|
|
423
|
+
* @method notExists
|
|
424
|
+
* @summary
|
|
425
|
+
* Property $exists query wrapper, checks if a field does not exists
|
|
426
|
+
* @description
|
|
427
|
+
* Compares the field/key provided against the provided value. Only documents that do not have the key are returned.
|
|
428
|
+
*
|
|
429
|
+
* Check mongodb query here: {@link https://docs.mongodb.com/manual/reference/operator/query/exists/}.
|
|
430
|
+
*
|
|
431
|
+
* Res: {@link https://docs.mongodb.com/manual/reference/method/db.collection.find/#type-bracketing}.
|
|
432
|
+
*
|
|
433
|
+
* Comparison ordering{
|
|
434
|
+
* @link https: //docs.mongodb.com/manual/reference/bson-type-comparison-order/#bson-types-comparison-order}
|
|
435
|
+
* @param {string} key Field to compare against
|
|
436
|
+
* @param {*} value Value to compare with
|
|
437
|
+
* @example
|
|
438
|
+
* Stack
|
|
439
|
+
* .contentType('')
|
|
440
|
+
* .entries()
|
|
441
|
+
* .notExists('emails')
|
|
442
|
+
* .find()
|
|
443
|
+
* .then((result) => {
|
|
444
|
+
* // filtered entries, where 'emails' property does not exist
|
|
445
|
+
* })
|
|
446
|
+
* .catch((error) => {
|
|
447
|
+
* // handle query errors
|
|
448
|
+
* })
|
|
449
|
+
*
|
|
450
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
451
|
+
*/
|
|
452
|
+
notExists(key: any): this;
|
|
453
|
+
/**
|
|
454
|
+
* @public
|
|
455
|
+
* @method contentType
|
|
456
|
+
* @summary Content type to query on
|
|
457
|
+
* @param {string} uid Content type uid
|
|
458
|
+
* @example
|
|
459
|
+
* Stack
|
|
460
|
+
* .contentType('blog')
|
|
461
|
+
* .entries()
|
|
462
|
+
* .find()
|
|
463
|
+
* .then((result) => {
|
|
464
|
+
* // returns entries filtered based on 'blog' content type
|
|
465
|
+
* })
|
|
466
|
+
* .catch((error) => {
|
|
467
|
+
* // handle query errors
|
|
468
|
+
* })
|
|
469
|
+
*
|
|
470
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
471
|
+
*/
|
|
472
|
+
contentType(uid: any): Stack;
|
|
473
|
+
/**
|
|
474
|
+
* @public
|
|
475
|
+
* @method entry
|
|
476
|
+
* @summary Query for a single entry
|
|
477
|
+
* @param {string} uid Entry uid to be found, if not provided,
|
|
478
|
+
* by default returns the 1st element in the content type.
|
|
479
|
+
* Useful for `singleton` content types
|
|
480
|
+
* @example
|
|
481
|
+
* Stack
|
|
482
|
+
* .contentType('blog')
|
|
483
|
+
* .entry()
|
|
484
|
+
* .find()
|
|
485
|
+
* .then((result) => {
|
|
486
|
+
* // returns the entry based on its 'uid',
|
|
487
|
+
* // if not provided, it would return the 1st entry found in 'blog' content type
|
|
488
|
+
* })
|
|
489
|
+
* .catch((error) => {
|
|
490
|
+
* // handle query errors
|
|
491
|
+
* })
|
|
492
|
+
*
|
|
493
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
494
|
+
*/
|
|
495
|
+
entry(uid?: any): this;
|
|
496
|
+
/**
|
|
497
|
+
* @public
|
|
498
|
+
* @method entries
|
|
499
|
+
* @description
|
|
500
|
+
* Query for a set of entries on a content type
|
|
501
|
+
*
|
|
502
|
+
* @example
|
|
503
|
+
* Stack
|
|
504
|
+
* .contentType('blog')
|
|
505
|
+
* .entries()
|
|
506
|
+
* .find()
|
|
507
|
+
* .then((result) => {
|
|
508
|
+
* // returns entries filtered based on 'blog' content type
|
|
509
|
+
* })
|
|
510
|
+
* .catch((error) => {
|
|
511
|
+
* // handle query errors
|
|
512
|
+
* })
|
|
513
|
+
*
|
|
514
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
515
|
+
*/
|
|
516
|
+
entries(): this;
|
|
517
|
+
/**
|
|
518
|
+
* @public
|
|
519
|
+
* @method asset
|
|
520
|
+
* @description
|
|
521
|
+
* Query for a single asset
|
|
522
|
+
*
|
|
523
|
+
* @param {string} uid Asset uid to be found, if not provided,
|
|
524
|
+
* by default returns the 1st element from assets.
|
|
525
|
+
* @example
|
|
526
|
+
* Stack
|
|
527
|
+
* .asset()
|
|
528
|
+
* .find()
|
|
529
|
+
* .then((result) => {
|
|
530
|
+
* // returns the asset based on its 'uid', if not provided, it would return the 1st asset found
|
|
531
|
+
* })
|
|
532
|
+
* .catch((error) => {
|
|
533
|
+
* // handle query errors
|
|
534
|
+
* })
|
|
535
|
+
*
|
|
536
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
537
|
+
*/
|
|
538
|
+
asset(uid?: any): Stack;
|
|
539
|
+
/**
|
|
540
|
+
* @public
|
|
541
|
+
* @method assets
|
|
542
|
+
* @description
|
|
543
|
+
* Query for a set of assets
|
|
544
|
+
*
|
|
545
|
+
* @example
|
|
546
|
+
* Stack
|
|
547
|
+
* .assets()
|
|
548
|
+
* .find()
|
|
549
|
+
* .then((result) => {
|
|
550
|
+
* // returns assets filtered based on 'blog' content type
|
|
551
|
+
* })
|
|
552
|
+
* .catch((error) => {
|
|
553
|
+
* // handle query errors
|
|
554
|
+
* })
|
|
555
|
+
*
|
|
556
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
557
|
+
*/
|
|
558
|
+
assets(): Stack;
|
|
559
|
+
/**
|
|
560
|
+
* @public
|
|
561
|
+
* @method schema
|
|
562
|
+
* @description
|
|
563
|
+
* Query for a single content type's schema
|
|
564
|
+
*
|
|
565
|
+
* @param {string} uid Content type uid to be found, if not provided,
|
|
566
|
+
* by default returns the 1st element from content types
|
|
567
|
+
*
|
|
568
|
+
* @example
|
|
569
|
+
* Stack
|
|
570
|
+
* .schema('blog')
|
|
571
|
+
* .find()
|
|
572
|
+
* .then((result) => {
|
|
573
|
+
* // returns content 'blog' content type's schema
|
|
574
|
+
* })
|
|
575
|
+
* .catch((error) => {
|
|
576
|
+
* // handle query errors
|
|
577
|
+
* })
|
|
578
|
+
*
|
|
579
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
580
|
+
*/
|
|
581
|
+
schema(uid?: any): Stack;
|
|
582
|
+
/**
|
|
583
|
+
* @public
|
|
584
|
+
* @method schemas
|
|
585
|
+
* @description
|
|
586
|
+
* Query for a set of content type schemas
|
|
587
|
+
* @example
|
|
588
|
+
* Stack
|
|
589
|
+
* .schemas()
|
|
590
|
+
* .find()
|
|
591
|
+
* .then((result) => {
|
|
592
|
+
* // returns a set of content type schemas
|
|
593
|
+
* })
|
|
594
|
+
* .catch((error) => {
|
|
595
|
+
* // handle query errors
|
|
596
|
+
* })
|
|
597
|
+
*
|
|
598
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
599
|
+
*/
|
|
600
|
+
schemas(): Stack;
|
|
601
|
+
/**
|
|
602
|
+
* @public
|
|
603
|
+
* @method contentTypes
|
|
604
|
+
* @description
|
|
605
|
+
* Query for a set of content type schemas
|
|
606
|
+
* @example
|
|
607
|
+
* Stack
|
|
608
|
+
* .contentTypes()
|
|
609
|
+
* .find()
|
|
610
|
+
* .then((result) => {
|
|
611
|
+
* // returns a set of content type schemas
|
|
612
|
+
* })
|
|
613
|
+
* .catch((error) => {
|
|
614
|
+
* // handle query errors
|
|
615
|
+
* })
|
|
616
|
+
*
|
|
617
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
618
|
+
*/
|
|
619
|
+
contentTypes(): Stack;
|
|
620
|
+
/**
|
|
621
|
+
* @public
|
|
622
|
+
* @method limit
|
|
623
|
+
* @description
|
|
624
|
+
* Parameter - used to limit the total no of items returned/scanned
|
|
625
|
+
* Defaults to 100 (internally, which is overridden)
|
|
626
|
+
* @param {number} no Max count of the 'items' returned
|
|
627
|
+
*
|
|
628
|
+
* @example
|
|
629
|
+
* Stack
|
|
630
|
+
* .contentType('blog')
|
|
631
|
+
* .entries()
|
|
632
|
+
* .limit(20)
|
|
633
|
+
* .find()
|
|
634
|
+
* .then((result) => {
|
|
635
|
+
* // returns a maximum of 20 entries
|
|
636
|
+
* // if not provided, by default - the limit specified in config is returned
|
|
637
|
+
* })
|
|
638
|
+
* .catch((error) => {
|
|
639
|
+
* // handle query errors
|
|
640
|
+
* })
|
|
641
|
+
*
|
|
642
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
643
|
+
*/
|
|
644
|
+
limit(no: any): this;
|
|
645
|
+
/**
|
|
646
|
+
* @public
|
|
647
|
+
* @method skip
|
|
648
|
+
* @description
|
|
649
|
+
* Parameter - used to skip initial no of items scanned
|
|
650
|
+
* Defaults to 0 (internally, which is overridden)
|
|
651
|
+
* @param {number} no Min count of the 'items' to be scanned
|
|
652
|
+
*
|
|
653
|
+
* @example
|
|
654
|
+
* Stack
|
|
655
|
+
* .contentType('blog')
|
|
656
|
+
* .entries()
|
|
657
|
+
* .skip(10)
|
|
658
|
+
* .find()
|
|
659
|
+
* .then((result) => {
|
|
660
|
+
* // returnes entries, after first skipping 20 entries of 'blog' content type
|
|
661
|
+
* // if not provided, by default - the skip value provided in config is considered
|
|
662
|
+
* })
|
|
663
|
+
* .catch((error) => {
|
|
664
|
+
* // handle query errors
|
|
665
|
+
* })
|
|
666
|
+
*
|
|
667
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
668
|
+
*/
|
|
669
|
+
skip(no: any): this;
|
|
670
|
+
/**
|
|
671
|
+
* @public
|
|
672
|
+
* @method query
|
|
673
|
+
* @description
|
|
674
|
+
* Wrapper around a raw query wrapper
|
|
675
|
+
* @param {object} queryObject Query filter
|
|
676
|
+
*
|
|
677
|
+
* @example
|
|
678
|
+
* Stack
|
|
679
|
+
* .contentType('blog')
|
|
680
|
+
* .entries()
|
|
681
|
+
* .query({"group.heading": "Tab 1"})
|
|
682
|
+
* .find()
|
|
683
|
+
* .then((result) => {
|
|
684
|
+
* // returns entries that have - {"group.heading": "Tab 1"}
|
|
685
|
+
* })
|
|
686
|
+
* .catch((error) => {
|
|
687
|
+
* // handle query errors
|
|
688
|
+
* })
|
|
689
|
+
*
|
|
690
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
691
|
+
*/
|
|
692
|
+
query(queryObject?: {}): this;
|
|
693
|
+
/**
|
|
694
|
+
* @public
|
|
695
|
+
* @method only
|
|
696
|
+
* @description
|
|
697
|
+
* Projections - returns only the fields passed here
|
|
698
|
+
*
|
|
699
|
+
* @param {array} fields Array of 'fields', separated by dot ('.') notation for embedded document query
|
|
700
|
+
*
|
|
701
|
+
* @example
|
|
702
|
+
* Stack
|
|
703
|
+
* .contentType('blog')
|
|
704
|
+
* .entries()
|
|
705
|
+
* .only(["title", "url", "links"])
|
|
706
|
+
* .find()
|
|
707
|
+
* .then((result) => {
|
|
708
|
+
* // returns entries and projects only their - ["title", "url", "links"] properties
|
|
709
|
+
* })
|
|
710
|
+
* .catch((error) => {
|
|
711
|
+
* // handle query errors
|
|
712
|
+
* })
|
|
713
|
+
*
|
|
714
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
715
|
+
*/
|
|
716
|
+
only(fields: any): this;
|
|
717
|
+
/**
|
|
718
|
+
* @public
|
|
719
|
+
* @method except
|
|
720
|
+
* @description
|
|
721
|
+
* Projections - returns fields except the ones passed here
|
|
722
|
+
*
|
|
723
|
+
* @param {array} fields Array of 'fields', separated by dot ('.') notation for embedded document query
|
|
724
|
+
* @example
|
|
725
|
+
* Stack
|
|
726
|
+
* .contentType('blog')
|
|
727
|
+
* .entries()
|
|
728
|
+
* .except(["title", "url", "links"])
|
|
729
|
+
* .find()
|
|
730
|
+
* .then((result) => {
|
|
731
|
+
* // returns entries and projects all of their properties, except - ["title", "url", "links"]
|
|
732
|
+
* })
|
|
733
|
+
* .catch((error) => {
|
|
734
|
+
* // handle query errors
|
|
735
|
+
* })
|
|
736
|
+
*
|
|
737
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
738
|
+
*/
|
|
739
|
+
except(fields: any): this;
|
|
740
|
+
/**
|
|
741
|
+
* @public
|
|
742
|
+
* @method regex
|
|
743
|
+
* @description
|
|
744
|
+
* Raw regex to be applied on a field - wrapper
|
|
745
|
+
*
|
|
746
|
+
* @param {string} field Field on which the regex is to be applied on
|
|
747
|
+
* @param {pattern} pattern Regex pattern
|
|
748
|
+
* @param {options} options Options to be applied while evaluating the regex
|
|
749
|
+
* @example
|
|
750
|
+
* Stack
|
|
751
|
+
* .contentType('blog')
|
|
752
|
+
* .entries()
|
|
753
|
+
* .regex("name", "^J")
|
|
754
|
+
* .find()
|
|
755
|
+
* .then((result) => {
|
|
756
|
+
* // returns entries who's name properties start with "J"
|
|
757
|
+
* })
|
|
758
|
+
* .catch((error) => {
|
|
759
|
+
* // handle query errors
|
|
760
|
+
* })
|
|
761
|
+
*
|
|
762
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
763
|
+
*/
|
|
764
|
+
regex(field: any, pattern: any, options?: string): this;
|
|
765
|
+
/**
|
|
766
|
+
* @public
|
|
767
|
+
* @method tags
|
|
768
|
+
* @summary Match entries that match a specific tags
|
|
769
|
+
*
|
|
770
|
+
* @param {array} values Array of tag values
|
|
771
|
+
* @example
|
|
772
|
+
* Stack
|
|
773
|
+
* .contentType('blog')
|
|
774
|
+
* .entries()
|
|
775
|
+
* .tags(["new", "fresh"])
|
|
776
|
+
* .find()
|
|
777
|
+
* .then((result) => {
|
|
778
|
+
* // returns entries filtered based on their tag fields
|
|
779
|
+
* })
|
|
780
|
+
* .catch((error) => {
|
|
781
|
+
* // handle query errors
|
|
782
|
+
* })
|
|
783
|
+
*
|
|
784
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
785
|
+
*/
|
|
786
|
+
tags(values: any): this;
|
|
787
|
+
/**
|
|
788
|
+
* @public
|
|
789
|
+
* @method where
|
|
790
|
+
* @summary Pass JS expression or a full function to the query system
|
|
791
|
+
* @description
|
|
792
|
+
* Use the $where operator to pass either a string containing a JavaScript expression or a full JavaScript
|
|
793
|
+
* function to the query system.
|
|
794
|
+
* The $where provides greater flexibility, but requires that the database processes the JavaScript expression or
|
|
795
|
+
* function for each document in the collection.
|
|
796
|
+
* Reference the document in the JavaScript expression or function using either this or obj.
|
|
797
|
+
* Only apply the $where query operator to top-level documents.
|
|
798
|
+
* The $where query operator will not work inside a nested document, for instance, in an $elemMatch query.
|
|
799
|
+
* Ref. - https://docs.mongodb.com/manual/reference/operator/query/where/index.html
|
|
800
|
+
* @param { * } expr Pass either a string containing a JavaScript expression or a full JavaScript
|
|
801
|
+
* function to the query system.
|
|
802
|
+
* @example
|
|
803
|
+
* Stack
|
|
804
|
+
* .contentType('blog')
|
|
805
|
+
* .entries()
|
|
806
|
+
* .where(function() {
|
|
807
|
+
* return (hex_md5(this.name) === "9b53e667f30cd329dca1ec9e6a83e994")
|
|
808
|
+
* })
|
|
809
|
+
* .find()
|
|
810
|
+
* .then((result) => {
|
|
811
|
+
* // returns entries filtered based on the $where condition provided
|
|
812
|
+
* })
|
|
813
|
+
* .catch((error) => {
|
|
814
|
+
* // handle query errors
|
|
815
|
+
* })
|
|
816
|
+
*
|
|
817
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
818
|
+
*/
|
|
819
|
+
where(expr: any): this;
|
|
820
|
+
/**
|
|
821
|
+
* @public
|
|
822
|
+
* @method includeCount
|
|
823
|
+
* @description
|
|
824
|
+
* Includes 'count' key in response, which is the total count of the items being returned
|
|
825
|
+
*
|
|
826
|
+
* @example
|
|
827
|
+
* Stack
|
|
828
|
+
* .contentType('blog')
|
|
829
|
+
* .entries()
|
|
830
|
+
* .includeCount()
|
|
831
|
+
* .find()
|
|
832
|
+
* .then((result) => {
|
|
833
|
+
* // returns entries, along with a 'count' property, with the total count of entries being returned
|
|
834
|
+
* })
|
|
835
|
+
* .catch((error) => {
|
|
836
|
+
* // handle query errors
|
|
837
|
+
* })
|
|
838
|
+
*
|
|
839
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
840
|
+
*/
|
|
841
|
+
includeCount(): this;
|
|
842
|
+
/**
|
|
843
|
+
* @description
|
|
844
|
+
* Includes 'content_type' key in response, which is the content type schema of the entries filtered/scanned
|
|
845
|
+
* @example
|
|
846
|
+
* Stack
|
|
847
|
+
* .contentType('blog')
|
|
848
|
+
* .entries()
|
|
849
|
+
* .includeSchema()
|
|
850
|
+
* .find()
|
|
851
|
+
* .then((result) => {
|
|
852
|
+
* // returns entries, along with a 'content_type' property, which is 'blog' content type's schema
|
|
853
|
+
* })
|
|
854
|
+
* .catch((error) => {
|
|
855
|
+
* // handle query errors
|
|
856
|
+
* })
|
|
857
|
+
*
|
|
858
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
859
|
+
*/
|
|
860
|
+
includeSchema(): this;
|
|
861
|
+
/**
|
|
862
|
+
* @public
|
|
863
|
+
* @method includeContentType
|
|
864
|
+
* @description
|
|
865
|
+
* Includes 'content_type' key in response, which is the content type schema of the entries filtered/scanned
|
|
866
|
+
* @example
|
|
867
|
+
* Stack
|
|
868
|
+
* .contentType('blog')
|
|
869
|
+
* .entries()
|
|
870
|
+
* .includeContentType()
|
|
871
|
+
* .find()
|
|
872
|
+
* .then((result) => {
|
|
873
|
+
* // returns entries, along with a 'content_type' property, which is 'blog' content type's schema
|
|
874
|
+
* })
|
|
875
|
+
* .catch((error) => {
|
|
876
|
+
* // handle query errors
|
|
877
|
+
* })
|
|
878
|
+
*
|
|
879
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
880
|
+
*/
|
|
881
|
+
includeContentType(): this;
|
|
882
|
+
/**
|
|
883
|
+
* @public
|
|
884
|
+
* @method excludeReferences
|
|
885
|
+
* @description
|
|
886
|
+
* Excludes all references of the entries being scanned.
|
|
887
|
+
* Note: On calling this, assets will not be binded in the result being returned.
|
|
888
|
+
*
|
|
889
|
+
* @example
|
|
890
|
+
* Stack
|
|
891
|
+
* .contentType('blog')
|
|
892
|
+
* .entries()
|
|
893
|
+
* .excludeReferences()
|
|
894
|
+
* .find()
|
|
895
|
+
* .then((result) => {
|
|
896
|
+
* // returns entries, without any of its assets Or references
|
|
897
|
+
* })
|
|
898
|
+
* .catch((error) => {
|
|
899
|
+
* // handle query errors
|
|
900
|
+
* })
|
|
901
|
+
*
|
|
902
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
903
|
+
*/
|
|
904
|
+
excludeReferences(): this;
|
|
905
|
+
/**
|
|
906
|
+
* @public
|
|
907
|
+
* @method queryReferences
|
|
908
|
+
* @description
|
|
909
|
+
* Wrapper, that allows querying on the entry's references.
|
|
910
|
+
* Note: This is a slow method, since it scans all documents and fires the `reference`
|
|
911
|
+
* query on them.Once the references are binded, the query object passed is used
|
|
912
|
+
* for filtering
|
|
913
|
+
* Use `.query()` filters to reduce the total no of documents being scanned
|
|
914
|
+
*
|
|
915
|
+
* @example
|
|
916
|
+
* Stack
|
|
917
|
+
* .contentType('blog')
|
|
918
|
+
* .entries()
|
|
919
|
+
* .queryReferences({"authors.name": "John Doe"})
|
|
920
|
+
* .find()
|
|
921
|
+
* .then((result) => {
|
|
922
|
+
* // returns entries, who's reference author's name equals "John Doe"
|
|
923
|
+
* })
|
|
924
|
+
* .catch((error) => {
|
|
925
|
+
* // handle query errors
|
|
926
|
+
* })
|
|
927
|
+
*
|
|
928
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
929
|
+
*/
|
|
930
|
+
queryReferences(query: any): this;
|
|
931
|
+
/**
|
|
932
|
+
* @public
|
|
933
|
+
* @method getQuery
|
|
934
|
+
* @description
|
|
935
|
+
* Returns the query build thusfar
|
|
936
|
+
* @example
|
|
937
|
+
* const query = Stack
|
|
938
|
+
* .contentType('blog')
|
|
939
|
+
* .entries()
|
|
940
|
+
* .getQuery()
|
|
941
|
+
* // exposes details of the queries formed inside the SDK
|
|
942
|
+
*
|
|
943
|
+
* @returns {Stack} Returns an instance of 'stack'
|
|
944
|
+
*/
|
|
945
|
+
getQuery(): any;
|
|
946
|
+
/**
|
|
947
|
+
* @public
|
|
948
|
+
* @method includeReferences
|
|
949
|
+
* @description
|
|
950
|
+
* This method would return all the references of your queried entries (until depth 2)
|
|
951
|
+
* Note: If you wish to increase the depth of the references fetched, call pass a numeric parameter
|
|
952
|
+
* @example
|
|
953
|
+
* Stack
|
|
954
|
+
* .contentType('blog')
|
|
955
|
+
* .entries()
|
|
956
|
+
* .includeReferences(3)
|
|
957
|
+
* @returns {Stack} Returns 'this' instance (of Stack)
|
|
958
|
+
*/
|
|
959
|
+
includeReferences(depth?: number): this;
|
|
960
|
+
/**
|
|
961
|
+
* @public
|
|
962
|
+
* @method include
|
|
963
|
+
* @description
|
|
964
|
+
* Pass in reference field uids, that you want included in your result.
|
|
965
|
+
* If you want all the references, use .includeReferences()
|
|
966
|
+
* @example
|
|
967
|
+
* Stack.contentType('blog')
|
|
968
|
+
* .entries()
|
|
969
|
+
* .include(['related_blogs', 'authors.blogs']) // here related_blogs and authors.blogs are reference field uids
|
|
970
|
+
* @param {object} fields An array of reference field uids
|
|
971
|
+
* @returns {Stack} Returns 'this' instance (of Stack)
|
|
972
|
+
*/
|
|
973
|
+
include(fields: any): this;
|
|
974
|
+
/**
|
|
975
|
+
* @public
|
|
976
|
+
* @method find
|
|
977
|
+
* @description
|
|
978
|
+
* Queries the db using the query built/passed
|
|
979
|
+
* Does all the processing, filtering, referencing after querying the DB
|
|
980
|
+
* @param {object} query Optional query object, that overrides all the
|
|
981
|
+
* previously build queries
|
|
982
|
+
* @public
|
|
983
|
+
* @example
|
|
984
|
+
* Stack
|
|
985
|
+
* .contentType('blog')
|
|
986
|
+
* .entries()
|
|
987
|
+
* .find()
|
|
988
|
+
* .then((result) => {
|
|
989
|
+
* // returns blog content type's entries
|
|
990
|
+
* })
|
|
991
|
+
* .catch((error) => {
|
|
992
|
+
* // handle query errors
|
|
993
|
+
* })
|
|
994
|
+
*
|
|
995
|
+
* @returns {object} - Returns a objects, that have been processed, filtered and referenced
|
|
996
|
+
*/
|
|
997
|
+
find(query?: {}): Promise<unknown>;
|
|
998
|
+
/**
|
|
999
|
+
* @public
|
|
1000
|
+
* @method count
|
|
1001
|
+
* @descriptionReturns the count of the entries/assets that match the filter
|
|
1002
|
+
* @param {object} query Optional query filter object
|
|
1003
|
+
* @public
|
|
1004
|
+
* @example
|
|
1005
|
+
* Stack
|
|
1006
|
+
* .contentType('blog')
|
|
1007
|
+
* .entries()
|
|
1008
|
+
* .count()
|
|
1009
|
+
* .then((result) => {
|
|
1010
|
+
* // returns entries, without any of its assets Or references
|
|
1011
|
+
* })
|
|
1012
|
+
* .catch((error) => {
|
|
1013
|
+
* // handle query errors
|
|
1014
|
+
* })
|
|
1015
|
+
*
|
|
1016
|
+
* @returns {object} Returns count of the entries/asset's matched
|
|
1017
|
+
*/
|
|
1018
|
+
count(query?: any): Promise<unknown>;
|
|
1019
|
+
/**
|
|
1020
|
+
* @public
|
|
1021
|
+
* @method findOne
|
|
1022
|
+
* @deprecated - Use .fetch() instead
|
|
1023
|
+
* @description
|
|
1024
|
+
* Queries the db using the query built/passed. Returns a single entry/asset/content type object
|
|
1025
|
+
* Does all the processing, filtering, referencing after querying the DB
|
|
1026
|
+
* @param {object} query Optional query object, that overrides all the previously build queries
|
|
1027
|
+
*
|
|
1028
|
+
* @example
|
|
1029
|
+
* Stack
|
|
1030
|
+
* .contentType('blog')
|
|
1031
|
+
* .entries()
|
|
1032
|
+
* .findOne()
|
|
1033
|
+
*
|
|
1034
|
+
* @returns {object} - Returns an object, that has been processed, filtered and referenced
|
|
1035
|
+
*/
|
|
1036
|
+
findOne(query?: {}): Promise<unknown>;
|
|
1037
|
+
/**
|
|
1038
|
+
* @public
|
|
1039
|
+
* @method fetch
|
|
1040
|
+
* @description
|
|
1041
|
+
* Queries the db using the query built/passed. Returns a single entry/asset/content type object
|
|
1042
|
+
* Does all the processing, filtering, referencing after querying the DB
|
|
1043
|
+
* @param {object} query Optional query object, that overrides all the previously build queries
|
|
1044
|
+
*
|
|
1045
|
+
* @example
|
|
1046
|
+
* Stack
|
|
1047
|
+
* .contentType('blog')
|
|
1048
|
+
* .entries()
|
|
1049
|
+
* .fetch()
|
|
1050
|
+
*
|
|
1051
|
+
* @returns {object} - Returns an object, that has been processed, filtered and referenced
|
|
1052
|
+
*/
|
|
1053
|
+
fetch(query?: {}): Promise<unknown>;
|
|
1054
|
+
/**
|
|
1055
|
+
* @private
|
|
1056
|
+
* @method preProcess
|
|
1057
|
+
* @summary Internal method, that executes and formats the queries built/passed
|
|
1058
|
+
* @param {object} query Query filter/process object
|
|
1059
|
+
* @returns {object} Returns a query object, that has been processed to be queried in mongodb
|
|
1060
|
+
*/
|
|
1061
|
+
private preProcess;
|
|
1062
|
+
/**
|
|
1063
|
+
* @private
|
|
1064
|
+
* @method cleanup
|
|
1065
|
+
* @summary Does GC, so memory doesn't stackup
|
|
1066
|
+
*/
|
|
1067
|
+
private cleanup;
|
|
1068
|
+
/**
|
|
1069
|
+
* @private
|
|
1070
|
+
* @method postProcess
|
|
1071
|
+
* @summary Internal method, that executes and formats the result, which the user and use
|
|
1072
|
+
* @param {object} result Result, which's to be manipulated
|
|
1073
|
+
* @returns {object} Returns the formatted version of the `result` object
|
|
1074
|
+
*/
|
|
1075
|
+
private postProcess;
|
|
1076
|
+
private includeAssetsOnly;
|
|
1077
|
+
/**
|
|
1078
|
+
* @summary
|
|
1079
|
+
* Internal method, that iteratively calls itself and binds entries reference
|
|
1080
|
+
* @param {Object} entry - An entry or a collection of entries, who's references are to be found
|
|
1081
|
+
* @param {String} contentTypeUid - Content type uid
|
|
1082
|
+
* @param {String} locale - Locale, in which the reference is to be found
|
|
1083
|
+
* @param {Object} include - Array of field paths, to be included
|
|
1084
|
+
* @returns {Object} - Returns `entries`, that has all of its reference binded
|
|
1085
|
+
*/
|
|
1086
|
+
private includeSpecificReferences;
|
|
1087
|
+
private fetchPathDetails;
|
|
1088
|
+
private bindLeftoverAssets;
|
|
1089
|
+
private includeReferenceIteration;
|
|
1090
|
+
private getReferencePath;
|
|
1091
|
+
private fetchEntries;
|
|
1092
|
+
private bindReferences;
|
|
1093
|
+
private includeAllReferencesIteration;
|
|
1094
|
+
private getAllReferencePaths;
|
|
1095
|
+
private sanitizeIQuery;
|
|
1096
|
+
private sanityQueryAny;
|
|
1097
|
+
}
|