Skip to content

Commit db9cece

Browse files
committed
backup
1 parent d03c74e commit db9cece

File tree

17 files changed

+1571
-1648
lines changed

17 files changed

+1571
-1648
lines changed

dist/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22
/*!
3-
* Contentstack Sync Mongodb SDK
3+
* Contentstack DataSync Mongodb SDK
44
* Copyright (c) 2019 Contentstack LLC
55
* MIT Licensed
66
*/

dist/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22
/*!
3-
* Contentstack Sync Mongodb SDK
3+
* Contentstack DataSync Mongodb SDK
44
* Copyright (c) 2019 Contentstack LLC
55
* MIT Licensed
66
*/

dist/stack.js

Lines changed: 102 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22
/*!
3-
* Contentstack Sync Mongodb SDK
3+
* Contentstack DataSync Mongodb SDK
44
* Copyright (c) 2019 Contentstack LLC
55
* MIT Licensed
66
*/
@@ -226,17 +226,19 @@ class Stack {
226226
* @returns {Stack} Returns an instance of 'stack'
227227
*/
228228
language(code) {
229-
if (!(code) || typeof code !== 'string' || !(lodash_1.find(this.config.locales, { code }))) {
229+
if (!(code) || typeof code !== 'string' || !(lodash_1.find(this.config.locales, {
230+
code
231+
}))) {
230232
throw new Error(`Language queried is invalid ${code}`);
231233
}
232234
this.q.locale = code;
233235
return this;
234236
}
235237
/**
238+
* @public
236239
* @method and
237-
* @description
238-
* Logical AND query wrapper
239-
*
240+
* @summary Logical AND query wrapper
241+
* @description Accepts 2 queries and returns only those documents, that satisfy both the query conditions
240242
* @param {object} queries Query filter
241243
* @example
242244
* Stack
@@ -274,10 +276,10 @@ class Stack {
274276
return this;
275277
}
276278
/**
279+
* @public
277280
* @method or
278-
* @description
279-
* Logical OR query wrapper
280-
*
281+
* @summary Logical OR query wrapper
282+
* @description Accepts 2 queries and returns only those documents, that satisfy either of the query conditions
281283
* @param {object} queries Query filter
282284
* @example
283285
* Stack
@@ -315,10 +317,12 @@ class Stack {
315317
return this;
316318
}
317319
/**
320+
* @public
318321
* @method lessThan
322+
* @summary Comparison $lt query wrapper
319323
* @description
320-
* Comparison $lt query wrapper
321-
*
324+
* Compares the field/key provided against the provided value. Only documents that have lower value than the one provided are returned.
325+
* Check https://docs.mongodb.com/manual/reference/operator/query/lt/ and https://docs.mongodb.com/manual/reference/method/db.collection.find/#type-bracketing for more info
322326
* @param {string} key Field to compare against
323327
* @param {*} value Value to compare with
324328
* @example
@@ -355,10 +359,12 @@ class Stack {
355359
return this;
356360
}
357361
/**
362+
* @public
358363
* @method lessThanOrEqualTo
364+
* @summary Comparison $lte query wrapper
359365
* @description
360-
* Comparison $lte query wrapper
361-
*
366+
* Compares the field/key provided against the provided value. Only documents that have lower or equal value than the one provided are returned.
367+
* Check https://docs.mongodb.com/manual/reference/operator/query/lte/ and https://docs.mongodb.com/manual/reference/method/db.collection.find/#type-bracketing for more info
362368
* @param {string} key Field to compare against
363369
* @param {*} value Value to compare with
364370
* @example
@@ -395,10 +401,12 @@ class Stack {
395401
return this;
396402
}
397403
/**
398-
* @member greaterThan
404+
* @public
405+
* @method greaterThan
406+
* @summary Comparison $gt query wrapper
399407
* @description
400-
* Comparison $gt query wrapper
401-
*
408+
* Compares the field/key provided against the provided value. Only documents that have greater value than the one provided are returned.
409+
* Check {@link https://docs.mongodb.com/manual/reference/operator/query/gt/ }and https://docs.mongodb.com/manual/reference/method/db.collection.find/#type-bracketing for more info
402410
* @param {string} key Field to compare against
403411
* @param {*} value Value to compare with
404412
* @example
@@ -435,9 +443,12 @@ class Stack {
435443
return this;
436444
}
437445
/**
446+
* @public
438447
* @method greaterThanOrEqualTo
448+
* @summary Comparison $gte query wrapper
439449
* @description
440-
* Comparison $gte query wrapper
450+
* Compares the field/key provided against the provided value. Only documents that have greater than or equal value than the one provided are returned.
451+
* Check https://docs.mongodb.com/manual/reference/operator/query/gte/ and https://docs.mongodb.com/manual/reference/method/db.collection.find/#type-bracketing for more info
441452
* @param {string} key - Field to compare against
442453
* @param {*} value - Value to compare with
443454
* @example
@@ -474,9 +485,17 @@ class Stack {
474485
return this;
475486
}
476487
/**
488+
* @public
477489
* @method notEqualTo
490+
* @summary Comparison $ne query wrapper
478491
* @description
479-
* Comparison $ne query wrapper
492+
* Compares the field/key provided against the provided value. Only documents that have value not equals than the one provided are returned.
493+
*
494+
* Check mongodb query here: {@link https://docs.mongodb.com/manual/reference/operator/query/ne/}.
495+
*
496+
* Res: {@link https://docs.mongodb.com/manual/reference/method/db.collection.find/#type-bracketing}.
497+
*
498+
* Comparison ordering {@link https://docs.mongodb.com/manual/reference/bson-type-comparison-order/#bson-types-comparison-order}
480499
* @param {string} key Field to compare against
481500
* @param {*} value Value to compare with
482501
* @example
@@ -513,9 +532,17 @@ class Stack {
513532
return this;
514533
}
515534
/**
535+
* @public
516536
* @method containedIn
537+
* @summary Comparison $in query wrapper
517538
* @description
518-
* Comparison $in query wrapper
539+
* Compares the field/key provided against the provided value. Only documents that have value contained in the field/key provided are returned.
540+
*
541+
* Check mongodb query here: {@link https://docs.mongodb.com/manual/reference/operator/query/in/}.
542+
*
543+
* Res: {@link https://docs.mongodb.com/manual/reference/method/db.collection.find/#type-bracketing}.
544+
*
545+
* Comparison ordering {@link https://docs.mongodb.com/manual/reference/bson-type-comparison-order/#bson-types-comparison-order}
519546
* @param {string} key Field to compare against
520547
* @param {*} value Value to compare with
521548
*
@@ -553,9 +580,17 @@ class Stack {
553580
return this;
554581
}
555582
/**
583+
* @public
556584
* @method notContainedIn
585+
* @summary Comparison $nin query wrapper
557586
* @description
558-
* Comparison $nin query wrapper
587+
* Compares the field/key provided against the provided value. Only documents that have value not contained in the field/key provided are returned.
588+
*
589+
* Check mongodb query here: {@link https://docs.mongodb.com/manual/reference/operator/query/nin/}.
590+
*
591+
* Res: {@link https://docs.mongodb.com/manual/reference/method/db.collection.find/#type-bracketing}.
592+
*
593+
* Comparison ordering {@link https://docs.mongodb.com/manual/reference/bson-type-comparison-order/#bson-types-comparison-order}
559594
* @param {string} key Field to compare against
560595
* @param {*} value Value to compare with
561596
*
@@ -593,10 +628,17 @@ class Stack {
593628
return this;
594629
}
595630
/**
631+
* @public
596632
* @method exists
633+
* @summary Element $exists query wrapper, checks if a field exists
597634
* @description
598-
* Element $exists query wrapper, checks if a field exists
635+
* Compares the field/key provided against the provided value. Only documents that have the field/key specified are returned.
599636
*
637+
* Check mongodb query here: {@link https://docs.mongodb.com/manual/reference/operator/query/exists/}.
638+
*
639+
* Res: {@link https://docs.mongodb.com/manual/reference/method/db.collection.find/#type-bracketing}.
640+
*
641+
* Comparison ordering {@link https://docs.mongodb.com/manual/reference/bson-type-comparison-order/#bson-types-comparison-order}
600642
* @param {string} key Field to compare against
601643
* @param {*} value Value to compare with
602644
*
@@ -634,10 +676,18 @@ class Stack {
634676
return this;
635677
}
636678
/**
679+
* @public
637680
* @method notExists
638-
* @description
681+
* @summary
639682
* Property $exists query wrapper, checks if a field does not exists
683+
* @description
684+
* Compares the field/key provided against the provided value. Only documents that do not have the key are returned.
640685
*
686+
* Check mongodb query here: {@link https://docs.mongodb.com/manual/reference/operator/query/exists/}.
687+
*
688+
* Res: {@link https://docs.mongodb.com/manual/reference/method/db.collection.find/#type-bracketing}.
689+
*
690+
* Comparison ordering {@link https://docs.mongodb.com/manual/reference/bson-type-comparison-order/#bson-types-comparison-order}
641691
* @param {string} key Field to compare against
642692
* @param {*} value Value to compare with
643693
* @example
@@ -674,10 +724,9 @@ class Stack {
674724
return this;
675725
}
676726
/**
727+
* @public
677728
* @method contentType
678-
* @description
679-
* Content type to query on
680-
*
729+
* @summary Content type to query on
681730
* @param {string} uid Content type uid
682731
* @example
683732
* Stack
@@ -704,11 +753,10 @@ class Stack {
704753
throw new Error('Kindly pass the content type\'s uid');
705754
}
706755
/**
756+
* @public
707757
* @method entry
708-
* @description
709-
* Query for a single entry
710-
*
711-
* @param {string} uid - Entry uid to be found, if not provided,
758+
* @summary Query for a single entry
759+
* @param {string} uid Entry uid to be found, if not provided,
712760
* by default returns the 1st element in the content type.
713761
* Useful for `singleton` content types
714762
* @example
@@ -1067,7 +1115,9 @@ class Stack {
10671115
return this;
10681116
}
10691117
/**
1070-
* Match entries that match a specific tags
1118+
* @public
1119+
* @method tags
1120+
* @summary Match entries that match a specific tags
10711121
*
10721122
* @param {array} values Array of tag values
10731123
* @example
@@ -1108,17 +1158,16 @@ class Stack {
11081158
return this;
11091159
}
11101160
/**
1111-
* @summary
1112-
* Pass JS expression or a full function to the query system
1113-
*
1161+
* @method where
1162+
* @summary Pass JS expression or a full function to the query system
11141163
* @description
11151164
* Use the $where operator to pass either a string containing a JavaScript expression or a full JavaScript function to the query system.
11161165
* The $where provides greater flexibility, but requires that the database processes the JavaScript expression or function for each document in the collection.
11171166
* Reference the document in the JavaScript expression or function using either this or obj.
11181167
* Only apply the $where query operator to top-level documents.
11191168
* The $where query operator will not work inside a nested document, for instance, in an $elemMatch query.
11201169
* Ref. - https://docs.mongodb.com/manual/reference/operator/query/where/index.html
1121-
* @param {*} expr - Pass either a string containing a JavaScript expression or a full JavaScript function to the query system.
1170+
* @param {*} expr Pass either a string containing a JavaScript expression or a full JavaScript function to the query system.
11221171
* @example
11231172
* Stack
11241173
* .contentType('blog')
@@ -1159,6 +1208,8 @@ class Stack {
11591208
return this;
11601209
}
11611210
/**
1211+
* @public
1212+
* @method includeCount
11621213
* @description
11631214
* Includes 'count' key in response, which is the total count of the items being returned
11641215
*
@@ -1362,13 +1413,18 @@ class Stack {
13621413
.toArray()
13631414
.then((result) => {
13641415
let contentType;
1365-
if (this.internal.includeSchema && this.q.content_type_uid !== 'contentTypes' && this.q.content_type_uid !==
1416+
if (this.internal.includeSchema && this.q.content_type_uid !== 'contentTypes' && this.q
1417+
.content_type_uid !==
13661418
'_assets') {
1367-
contentType = lodash_1.remove(result, { uid: this.q.content_type_uid });
1368-
contentType = (typeof contentType === 'object' && contentType instanceof Array && contentType.length) ?
1419+
contentType = lodash_1.remove(result, {
1420+
uid: this.q.content_type_uid
1421+
});
1422+
contentType = (typeof contentType === 'object' && contentType instanceof Array && contentType
1423+
.length) ?
13691424
contentType[0] : null;
13701425
}
1371-
if (this.internal.excludeReferences || this.q.content_type_uid === 'contentTypes' || this.q.content_type_uid
1426+
if (this.internal.excludeReferences || this.q.content_type_uid === 'contentTypes' || this.q
1427+
.content_type_uid
13721428
=== '_assets') {
13731429
result = this.postProcess(result, contentType);
13741430
return resolve(result);
@@ -1421,15 +1477,19 @@ class Stack {
14211477
.toArray()
14221478
.then((result) => {
14231479
if (result === null || result.length === 0) {
1424-
return resolve({ count: 0 });
1480+
return resolve({
1481+
count: 0
1482+
});
14251483
}
14261484
this.internal.includeReferences = true;
14271485
return this.includeReferencesI(result, this.q.locale, {}, undefined)
14281486
.then(() => {
14291487
result = sift_1.default(this.internal.queryReferences, result);
14301488
result = result.length;
14311489
this.cleanup();
1432-
return resolve({ count: result });
1490+
return resolve({
1491+
count: result
1492+
});
14331493
});
14341494
})
14351495
.catch((error) => {
@@ -1442,7 +1502,9 @@ class Stack {
14421502
.count()
14431503
.then((result) => {
14441504
this.cleanup();
1445-
return resolve({ count: result });
1505+
return resolve({
1506+
count: result
1507+
});
14461508
})
14471509
.catch((error) => {
14481510
this.cleanup();

dist/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22
/*!
3-
* Contentstack Sync Mongodb SDK
3+
* Contentstack DataSync Mongodb SDK
44
* Copyright (c) 2019 Contentstack LLC
55
* MIT Licensed
66
*/

0 commit comments

Comments
 (0)