mongoose 9.2.2 → 9.2.4
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/lib/aggregate.js +41 -41
- package/lib/cast/bigint.js +2 -2
- package/lib/cast/boolean.js +3 -3
- package/lib/cast/double.js +2 -2
- package/lib/cast/int32.js +2 -2
- package/lib/cast/number.js +2 -2
- package/lib/cast/string.js +2 -2
- package/lib/cast.js +6 -6
- package/lib/collection.js +4 -4
- package/lib/connection.js +58 -58
- package/lib/cursor/aggregationCursor.js +6 -6
- package/lib/cursor/queryCursor.js +7 -7
- package/lib/document.js +176 -176
- package/lib/drivers/node-mongodb-native/collection.js +2 -2
- package/lib/drivers/node-mongodb-native/connection.js +8 -8
- package/lib/error/cast.js +2 -2
- package/lib/error/createCollectionsError.js +2 -2
- package/lib/error/divergentArray.js +1 -1
- package/lib/error/eachAsyncMultiError.js +1 -1
- package/lib/error/index.js +2 -2
- package/lib/error/invalidSchemaOption.js +1 -1
- package/lib/error/missingSchema.js +1 -1
- package/lib/error/objectParameter.js +3 -3
- package/lib/error/overwriteModel.js +1 -1
- package/lib/error/setOptionError.js +3 -3
- package/lib/error/strict.js +3 -3
- package/lib/error/strictPopulate.js +2 -2
- package/lib/error/syncIndexes.js +2 -2
- package/lib/error/validation.js +2 -2
- package/lib/error/validator.js +1 -1
- package/lib/error/version.js +2 -2
- package/lib/helpers/buildMiddlewareFilter.js +2 -2
- package/lib/helpers/clone.js +4 -4
- package/lib/helpers/createJSONSchemaTypeDefinition.js +4 -4
- package/lib/helpers/cursor/eachAsync.js +3 -3
- package/lib/helpers/discriminator/getDiscriminatorByValue.js +1 -1
- package/lib/helpers/discriminator/mergeDiscriminatorSchema.js +3 -3
- package/lib/helpers/document/applyTimestamps.js +9 -9
- package/lib/helpers/document/applyVirtuals.js +6 -6
- package/lib/helpers/document/compile.js +10 -10
- package/lib/helpers/document/getDeepestSubdocumentForPath.js +2 -2
- package/lib/helpers/document/getEmbeddedDiscriminatorPath.js +2 -2
- package/lib/helpers/indexes/isIndexEqual.js +3 -3
- package/lib/helpers/indexes/isIndexSpecEqual.js +3 -3
- package/lib/helpers/isMongooseObject.js +1 -1
- package/lib/helpers/isObject.js +2 -2
- package/lib/helpers/isSimpleValidator.js +2 -2
- package/lib/helpers/minimize.js +2 -2
- package/lib/helpers/model/applyHooks.js +1 -1
- package/lib/helpers/model/castBulkWrite.js +2 -2
- package/lib/helpers/pluralize.js +1 -1
- package/lib/helpers/populate/assignRawDocsToIdStructure.js +2 -2
- package/lib/helpers/populate/assignVals.js +6 -6
- package/lib/helpers/populate/createPopulateQueryFilter.js +2 -2
- package/lib/helpers/populate/getModelsMapForPopulate.js +12 -12
- package/lib/helpers/populate/getSchemaTypes.js +1 -1
- package/lib/helpers/populate/markArraySubdocsPopulated.js +1 -1
- package/lib/helpers/populate/setPopulatedVirtualValue.js +5 -5
- package/lib/helpers/projection/hasIncludedChildren.js +1 -1
- package/lib/helpers/projection/isPathExcluded.js +3 -3
- package/lib/helpers/projection/isSubpath.js +1 -1
- package/lib/helpers/query/castUpdate.js +14 -14
- package/lib/helpers/query/getEmbeddedDiscriminatorPath.js +4 -4
- package/lib/helpers/query/handleImmutable.js +6 -6
- package/lib/helpers/schema/getIndexes.js +1 -1
- package/lib/helpers/schema/getSubdocumentStrictValue.js +1 -1
- package/lib/helpers/setDefaultsOnInsert.js +3 -3
- package/lib/helpers/update/modifiedPaths.js +2 -2
- package/lib/helpers/updateValidators.js +2 -2
- package/lib/model.js +263 -263
- package/lib/mongoose.js +54 -54
- package/lib/options/schemaArrayOptions.js +2 -2
- package/lib/options/schemaBufferOptions.js +1 -1
- package/lib/options/schemaNumberOptions.js +3 -3
- package/lib/options/schemaObjectIdOptions.js +2 -2
- package/lib/options/schemaStringOptions.js +6 -6
- package/lib/options/schemaTypeOptions.js +13 -13
- package/lib/options/virtualOptions.js +11 -11
- package/lib/query.js +222 -222
- package/lib/queryHelpers.js +4 -4
- package/lib/schema/array.js +18 -18
- package/lib/schema/bigint.js +13 -13
- package/lib/schema/boolean.js +13 -13
- package/lib/schema/buffer.js +14 -14
- package/lib/schema/date.js +16 -16
- package/lib/schema/decimal128.js +13 -13
- package/lib/schema/documentArray.js +15 -15
- package/lib/schema/documentArrayElement.js +5 -6
- package/lib/schema/double.js +12 -12
- package/lib/schema/int32.js +13 -13
- package/lib/schema/map.js +10 -10
- package/lib/schema/mixed.js +10 -10
- package/lib/schema/number.js +18 -18
- package/lib/schema/objectId.js +14 -14
- package/lib/schema/operators/text.js +3 -3
- package/lib/schema/string.js +17 -17
- package/lib/schema/subdocument.js +13 -13
- package/lib/schema/union.js +3 -3
- package/lib/schema/uuid.js +16 -16
- package/lib/schema.js +76 -76
- package/lib/schemaType.js +62 -62
- package/lib/stateMachine.js +5 -8
- package/lib/types/array/index.js +1 -1
- package/lib/types/array/methods/index.js +12 -12
- package/lib/types/arraySubdocument.js +8 -8
- package/lib/types/buffer.js +4 -4
- package/lib/types/documentArray/index.js +1 -1
- package/lib/types/documentArray/methods/index.js +5 -5
- package/lib/types/map.js +3 -3
- package/lib/types/subdocument.js +11 -11
- package/lib/utils.js +45 -45
- package/lib/virtualType.js +18 -18
- package/package.json +8 -5
- package/types/index.d.ts +16 -15
- package/types/inferschematype.d.ts +10 -0
- package/types/models.d.ts +8 -5
- package/types/schemaoptions.d.ts +1 -1
- package/types/virtuals.d.ts +10 -10
package/lib/query.js
CHANGED
|
@@ -101,10 +101,10 @@ const opToThunk = new Map([
|
|
|
101
101
|
* // this unless you're an advanced user with a very good reason to.
|
|
102
102
|
* const query = new mongoose.Query();
|
|
103
103
|
*
|
|
104
|
-
* @param {
|
|
105
|
-
* @param {
|
|
106
|
-
* @param {
|
|
107
|
-
* @param {
|
|
104
|
+
* @param {object} [options]
|
|
105
|
+
* @param {object} [model]
|
|
106
|
+
* @param {object} [conditions]
|
|
107
|
+
* @param {object} [collection] Mongoose collection
|
|
108
108
|
* @api public
|
|
109
109
|
*/
|
|
110
110
|
|
|
@@ -379,7 +379,7 @@ Query.prototype.clone = function() {
|
|
|
379
379
|
*
|
|
380
380
|
* @see $where https://www.mongodb.com/docs/manual/reference/operator/where/
|
|
381
381
|
* @method $where
|
|
382
|
-
* @param {
|
|
382
|
+
* @param {string|Function} js javascript string or function
|
|
383
383
|
* @return {Query} this
|
|
384
384
|
* @memberOf Query
|
|
385
385
|
* @instance
|
|
@@ -411,7 +411,7 @@ Query.prototype.clone = function() {
|
|
|
411
411
|
* @method where
|
|
412
412
|
* @memberOf Query
|
|
413
413
|
* @instance
|
|
414
|
-
* @param {
|
|
414
|
+
* @param {string|object} [path]
|
|
415
415
|
* @param {any} [val]
|
|
416
416
|
* @return {Query} this
|
|
417
417
|
* @api public
|
|
@@ -447,8 +447,8 @@ Query.prototype.clone = function() {
|
|
|
447
447
|
* @method slice
|
|
448
448
|
* @memberOf Query
|
|
449
449
|
* @instance
|
|
450
|
-
* @param {
|
|
451
|
-
* @param {
|
|
450
|
+
* @param {string} [path]
|
|
451
|
+
* @param {number|Array} val number of elements to slice or array with number of elements to skip and number of elements to slice
|
|
452
452
|
* @return {Query} this
|
|
453
453
|
* @see mongodb https://www.mongodb.com/docs/manual/tutorial/query-documents/#projection
|
|
454
454
|
* @see $slice https://www.mongodb.com/docs/manual/reference/projection/slice/#prj._S_slice
|
|
@@ -529,7 +529,7 @@ Query.prototype._validateOp = function() {
|
|
|
529
529
|
* @method equals
|
|
530
530
|
* @memberOf Query
|
|
531
531
|
* @instance
|
|
532
|
-
* @param {
|
|
532
|
+
* @param {object} val
|
|
533
533
|
* @return {Query} this
|
|
534
534
|
* @api public
|
|
535
535
|
*/
|
|
@@ -597,8 +597,8 @@ Query.prototype._validateOp = function() {
|
|
|
597
597
|
* @method gt
|
|
598
598
|
* @memberOf Query
|
|
599
599
|
* @instance
|
|
600
|
-
* @param {
|
|
601
|
-
* @param {
|
|
600
|
+
* @param {string} [path]
|
|
601
|
+
* @param {number} val
|
|
602
602
|
* @see $gt https://www.mongodb.com/docs/manual/reference/operator/gt/
|
|
603
603
|
* @api public
|
|
604
604
|
*/
|
|
@@ -611,8 +611,8 @@ Query.prototype._validateOp = function() {
|
|
|
611
611
|
* @method gte
|
|
612
612
|
* @memberOf Query
|
|
613
613
|
* @instance
|
|
614
|
-
* @param {
|
|
615
|
-
* @param {
|
|
614
|
+
* @param {string} [path]
|
|
615
|
+
* @param {number} val
|
|
616
616
|
* @see $gte https://www.mongodb.com/docs/manual/reference/operator/gte/
|
|
617
617
|
* @api public
|
|
618
618
|
*/
|
|
@@ -625,8 +625,8 @@ Query.prototype._validateOp = function() {
|
|
|
625
625
|
* @method lt
|
|
626
626
|
* @memberOf Query
|
|
627
627
|
* @instance
|
|
628
|
-
* @param {
|
|
629
|
-
* @param {
|
|
628
|
+
* @param {string} [path]
|
|
629
|
+
* @param {number} val
|
|
630
630
|
* @see $lt https://www.mongodb.com/docs/manual/reference/operator/lt/
|
|
631
631
|
* @api public
|
|
632
632
|
*/
|
|
@@ -640,8 +640,8 @@ Query.prototype._validateOp = function() {
|
|
|
640
640
|
* @see $lte https://www.mongodb.com/docs/manual/reference/operator/lte/
|
|
641
641
|
* @memberOf Query
|
|
642
642
|
* @instance
|
|
643
|
-
* @param {
|
|
644
|
-
* @param {
|
|
643
|
+
* @param {string} [path]
|
|
644
|
+
* @param {number} val
|
|
645
645
|
* @api public
|
|
646
646
|
*/
|
|
647
647
|
|
|
@@ -654,7 +654,7 @@ Query.prototype._validateOp = function() {
|
|
|
654
654
|
* @method ne
|
|
655
655
|
* @memberOf Query
|
|
656
656
|
* @instance
|
|
657
|
-
* @param {
|
|
657
|
+
* @param {string} [path]
|
|
658
658
|
* @param {any} val
|
|
659
659
|
* @api public
|
|
660
660
|
*/
|
|
@@ -668,7 +668,7 @@ Query.prototype._validateOp = function() {
|
|
|
668
668
|
* @method in
|
|
669
669
|
* @memberOf Query
|
|
670
670
|
* @instance
|
|
671
|
-
* @param {
|
|
671
|
+
* @param {string} [path]
|
|
672
672
|
* @param {Array} val
|
|
673
673
|
* @api public
|
|
674
674
|
*/
|
|
@@ -682,7 +682,7 @@ Query.prototype._validateOp = function() {
|
|
|
682
682
|
* @method nin
|
|
683
683
|
* @memberOf Query
|
|
684
684
|
* @instance
|
|
685
|
-
* @param {
|
|
685
|
+
* @param {string} [path]
|
|
686
686
|
* @param {Array} val
|
|
687
687
|
* @api public
|
|
688
688
|
*/
|
|
@@ -702,7 +702,7 @@ Query.prototype._validateOp = function() {
|
|
|
702
702
|
* @method all
|
|
703
703
|
* @memberOf Query
|
|
704
704
|
* @instance
|
|
705
|
-
* @param {
|
|
705
|
+
* @param {string} [path]
|
|
706
706
|
* @param {Array} val
|
|
707
707
|
* @api public
|
|
708
708
|
*/
|
|
@@ -722,8 +722,8 @@ Query.prototype._validateOp = function() {
|
|
|
722
722
|
* @method size
|
|
723
723
|
* @memberOf Query
|
|
724
724
|
* @instance
|
|
725
|
-
* @param {
|
|
726
|
-
* @param {
|
|
725
|
+
* @param {string} [path]
|
|
726
|
+
* @param {number} val
|
|
727
727
|
* @api public
|
|
728
728
|
*/
|
|
729
729
|
|
|
@@ -736,8 +736,8 @@ Query.prototype._validateOp = function() {
|
|
|
736
736
|
* @method regex
|
|
737
737
|
* @memberOf Query
|
|
738
738
|
* @instance
|
|
739
|
-
* @param {
|
|
740
|
-
* @param {
|
|
739
|
+
* @param {string} [path]
|
|
740
|
+
* @param {string|RegExp} val
|
|
741
741
|
* @api public
|
|
742
742
|
*/
|
|
743
743
|
|
|
@@ -750,8 +750,8 @@ Query.prototype._validateOp = function() {
|
|
|
750
750
|
* @method maxDistance
|
|
751
751
|
* @memberOf Query
|
|
752
752
|
* @instance
|
|
753
|
-
* @param {
|
|
754
|
-
* @param {
|
|
753
|
+
* @param {string} [path]
|
|
754
|
+
* @param {number} val
|
|
755
755
|
* @api public
|
|
756
756
|
*/
|
|
757
757
|
|
|
@@ -770,7 +770,7 @@ Query.prototype._validateOp = function() {
|
|
|
770
770
|
* @method mod
|
|
771
771
|
* @memberOf Query
|
|
772
772
|
* @instance
|
|
773
|
-
* @param {
|
|
773
|
+
* @param {string} [path]
|
|
774
774
|
* @param {Array} val must be of length 2, first element is `divisor`, 2nd element is `remainder`.
|
|
775
775
|
* @return {Query} this
|
|
776
776
|
* @see $mod https://www.mongodb.com/docs/manual/reference/operator/mod/
|
|
@@ -819,8 +819,8 @@ Query.prototype.mod = function() {
|
|
|
819
819
|
* @method exists
|
|
820
820
|
* @memberOf Query
|
|
821
821
|
* @instance
|
|
822
|
-
* @param {
|
|
823
|
-
* @param {
|
|
822
|
+
* @param {string} [path]
|
|
823
|
+
* @param {boolean} val
|
|
824
824
|
* @return {Query} this
|
|
825
825
|
* @see $exists https://www.mongodb.com/docs/manual/reference/operator/exists/
|
|
826
826
|
* @api public
|
|
@@ -848,8 +848,8 @@ Query.prototype.mod = function() {
|
|
|
848
848
|
* @method elemMatch
|
|
849
849
|
* @memberOf Query
|
|
850
850
|
* @instance
|
|
851
|
-
* @param {
|
|
852
|
-
* @param {
|
|
851
|
+
* @param {string|object|Function} path
|
|
852
|
+
* @param {object|Function} filter
|
|
853
853
|
* @return {Query} this
|
|
854
854
|
* @see $elemMatch https://www.mongodb.com/docs/manual/reference/operator/elemMatch/
|
|
855
855
|
* @api public
|
|
@@ -908,7 +908,7 @@ Query.prototype.mod = function() {
|
|
|
908
908
|
* @method limit
|
|
909
909
|
* @memberOf Query
|
|
910
910
|
* @instance
|
|
911
|
-
* @param {
|
|
911
|
+
* @param {number} val
|
|
912
912
|
* @api public
|
|
913
913
|
*/
|
|
914
914
|
|
|
@@ -941,7 +941,7 @@ Query.prototype.limit = function limit(v) {
|
|
|
941
941
|
* @method skip
|
|
942
942
|
* @memberOf Query
|
|
943
943
|
* @instance
|
|
944
|
-
* @param {
|
|
944
|
+
* @param {number} val
|
|
945
945
|
* @see cursor.skip https://www.mongodb.com/docs/manual/reference/method/cursor.skip/
|
|
946
946
|
* @api public
|
|
947
947
|
*/
|
|
@@ -975,7 +975,7 @@ Query.prototype.skip = function skip(v) {
|
|
|
975
975
|
* @method batchSize
|
|
976
976
|
* @memberOf Query
|
|
977
977
|
* @instance
|
|
978
|
-
* @param {
|
|
978
|
+
* @param {number} val
|
|
979
979
|
* @see batchSize https://www.mongodb.com/docs/manual/reference/method/cursor.batchSize/
|
|
980
980
|
* @api public
|
|
981
981
|
*/
|
|
@@ -994,7 +994,7 @@ Query.prototype.skip = function skip(v) {
|
|
|
994
994
|
* @method comment
|
|
995
995
|
* @memberOf Query
|
|
996
996
|
* @instance
|
|
997
|
-
* @param {
|
|
997
|
+
* @param {string} val
|
|
998
998
|
* @see comment https://www.mongodb.com/docs/manual/reference/operator/comment/
|
|
999
999
|
* @api public
|
|
1000
1000
|
*/
|
|
@@ -1013,7 +1013,7 @@ Query.prototype.skip = function skip(v) {
|
|
|
1013
1013
|
* @method hint
|
|
1014
1014
|
* @memberOf Query
|
|
1015
1015
|
* @instance
|
|
1016
|
-
* @param {
|
|
1016
|
+
* @param {object} val a hint object
|
|
1017
1017
|
* @return {Query} this
|
|
1018
1018
|
* @see $hint https://www.mongodb.com/docs/manual/reference/operator/hint/
|
|
1019
1019
|
* @api public
|
|
@@ -1044,8 +1044,8 @@ Query.prototype.skip = function skip(v) {
|
|
|
1044
1044
|
* @method projection
|
|
1045
1045
|
* @memberOf Query
|
|
1046
1046
|
* @instance
|
|
1047
|
-
* @param {
|
|
1048
|
-
* @return {
|
|
1047
|
+
* @param {object|null} arg
|
|
1048
|
+
* @return {object} the current projection
|
|
1049
1049
|
* @api public
|
|
1050
1050
|
*/
|
|
1051
1051
|
|
|
@@ -1102,7 +1102,7 @@ Query.prototype.projection = function(arg) {
|
|
|
1102
1102
|
* @method select
|
|
1103
1103
|
* @memberOf Query
|
|
1104
1104
|
* @instance
|
|
1105
|
-
* @param {
|
|
1105
|
+
* @param {object|string|Array<string>} arg
|
|
1106
1106
|
* @return {Query} this
|
|
1107
1107
|
* @see SchemaType https://mongoosejs.com/docs/api/schematype.html
|
|
1108
1108
|
* @api public
|
|
@@ -1206,7 +1206,7 @@ Query.prototype.select = function select() {
|
|
|
1206
1206
|
* @method schemaLevelProjections
|
|
1207
1207
|
* @memberOf Query
|
|
1208
1208
|
* @instance
|
|
1209
|
-
* @param {
|
|
1209
|
+
* @param {boolean} value
|
|
1210
1210
|
* @return {Query} this
|
|
1211
1211
|
* @see SchemaTypeOptions https://mongoosejs.com/docs/schematypes.html#all-schema-types
|
|
1212
1212
|
* @api public
|
|
@@ -1259,7 +1259,7 @@ Query.prototype.schemaLevelProjections = function schemaLevelProjections(value)
|
|
|
1259
1259
|
* @method sanitizeProjection
|
|
1260
1260
|
* @memberOf Query
|
|
1261
1261
|
* @instance
|
|
1262
|
-
* @param {
|
|
1262
|
+
* @param {boolean} value
|
|
1263
1263
|
* @return {Query} this
|
|
1264
1264
|
* @see sanitizeProjection https://thecodebarbarian.com/whats-new-in-mongoose-5-13-sanitizeprojection.html
|
|
1265
1265
|
* @api public
|
|
@@ -1319,7 +1319,7 @@ Query.prototype.sanitizeProjection = function sanitizeProjection(value) {
|
|
|
1319
1319
|
* @method read
|
|
1320
1320
|
* @memberOf Query
|
|
1321
1321
|
* @instance
|
|
1322
|
-
* @param {
|
|
1322
|
+
* @param {string} mode one of the listed preference options or aliases
|
|
1323
1323
|
* @param {Array} [tags] optional tags for this query
|
|
1324
1324
|
* @see mongodb https://www.mongodb.com/docs/manual/applications/replication/#read-preference
|
|
1325
1325
|
* @return {Query} this
|
|
@@ -1432,7 +1432,7 @@ Query.prototype.session = function session(v) {
|
|
|
1432
1432
|
* @method writeConcern
|
|
1433
1433
|
* @memberOf Query
|
|
1434
1434
|
* @instance
|
|
1435
|
-
* @param {
|
|
1435
|
+
* @param {object} writeConcern the write concern value to set
|
|
1436
1436
|
* @see WriteConcernSettings https://mongodb.github.io/node-mongodb-native/4.9/interfaces/WriteConcernSettings.html
|
|
1437
1437
|
* @return {Query} this
|
|
1438
1438
|
* @api public
|
|
@@ -1473,7 +1473,7 @@ Query.prototype.writeConcern = function writeConcern(val) {
|
|
|
1473
1473
|
* @method w
|
|
1474
1474
|
* @memberOf Query
|
|
1475
1475
|
* @instance
|
|
1476
|
-
* @param {
|
|
1476
|
+
* @param {string|number} val 0 for fire-and-forget, 1 for acknowledged by one server, 'majority' for majority of the replica set, or [any of the more advanced options](https://www.mongodb.com/docs/manual/reference/write-concern/#w-option).
|
|
1477
1477
|
* @see mongodb https://www.mongodb.com/docs/manual/reference/write-concern/#w-option
|
|
1478
1478
|
* @return {Query} this
|
|
1479
1479
|
* @api public
|
|
@@ -1640,7 +1640,7 @@ Query.prototype.wtimeout = function wtimeout(ms) {
|
|
|
1640
1640
|
* query.setOptions({ maxTimeMS: 1000 });
|
|
1641
1641
|
* query.getOptions(); // { limit: 10, maxTimeMS: 1000 }
|
|
1642
1642
|
*
|
|
1643
|
-
* @return {
|
|
1643
|
+
* @return {object} the options
|
|
1644
1644
|
* @api public
|
|
1645
1645
|
*/
|
|
1646
1646
|
|
|
@@ -1700,7 +1700,7 @@ Query.prototype.getOptions = function() {
|
|
|
1700
1700
|
* - [explain](https://www.mongodb.com/docs/manual/reference/method/cursor.explain/)
|
|
1701
1701
|
* - [middleware](https://mongoosejs.com/docs/middleware.html#skipping): set to `false` to skip all user-defined middleware, or `{ pre: false }` / `{ post: false }` to skip only pre or post hooks
|
|
1702
1702
|
*
|
|
1703
|
-
* @param {
|
|
1703
|
+
* @param {object} options
|
|
1704
1704
|
* @return {Query} this
|
|
1705
1705
|
* @api public
|
|
1706
1706
|
*/
|
|
@@ -1860,7 +1860,7 @@ Query.prototype.explain = function explain(verbose) {
|
|
|
1860
1860
|
* // Equivalent:
|
|
1861
1861
|
* await query.find().sort({ name: 1 }).allowDiskUse();
|
|
1862
1862
|
*
|
|
1863
|
-
* @param {
|
|
1863
|
+
* @param {boolean} [v] Enable/disable `allowDiskUse`. If called with 0 arguments, sets `allowDiskUse: true`
|
|
1864
1864
|
* @return {Query} this
|
|
1865
1865
|
* @api public
|
|
1866
1866
|
*/
|
|
@@ -1890,7 +1890,7 @@ Query.prototype.allowDiskUse = function(v) {
|
|
|
1890
1890
|
* // >= 1 doc in the queried collection
|
|
1891
1891
|
* const res = await query.find({ $where: 'sleep(1000) || true' }).maxTimeMS(100);
|
|
1892
1892
|
*
|
|
1893
|
-
* @param {
|
|
1893
|
+
* @param {number} [ms] The number of milliseconds
|
|
1894
1894
|
* @return {Query} this
|
|
1895
1895
|
* @api public
|
|
1896
1896
|
*/
|
|
@@ -1909,7 +1909,7 @@ Query.prototype.maxTimeMS = function(ms) {
|
|
|
1909
1909
|
* query.find({ a: 1 }).where('b').gt(2);
|
|
1910
1910
|
* query.getFilter(); // { a: 1, b: { $gt: 2 } }
|
|
1911
1911
|
*
|
|
1912
|
-
* @return {
|
|
1912
|
+
* @return {object} current query filter
|
|
1913
1913
|
* @api public
|
|
1914
1914
|
*/
|
|
1915
1915
|
|
|
@@ -1929,7 +1929,7 @@ Query.prototype.getFilter = function() {
|
|
|
1929
1929
|
* query.find({ a: 1 }).where('b').gt(2);
|
|
1930
1930
|
* query.getQuery(); // { a: 1, b: { $gt: 2 } }
|
|
1931
1931
|
*
|
|
1932
|
-
* @return {
|
|
1932
|
+
* @return {object} current query filter
|
|
1933
1933
|
* @api public
|
|
1934
1934
|
*/
|
|
1935
1935
|
|
|
@@ -1947,7 +1947,7 @@ Query.prototype.getQuery = function() {
|
|
|
1947
1947
|
* query.setQuery({ a: 2 });
|
|
1948
1948
|
* query.getQuery(); // { a: 2 }
|
|
1949
1949
|
*
|
|
1950
|
-
* @param {
|
|
1950
|
+
* @param {object} new query conditions
|
|
1951
1951
|
* @return {undefined}
|
|
1952
1952
|
* @api public
|
|
1953
1953
|
*/
|
|
@@ -1965,7 +1965,7 @@ Query.prototype.setQuery = function(val) {
|
|
|
1965
1965
|
* query.updateOne({}, { $set: { a: 5 } });
|
|
1966
1966
|
* query.getUpdate(); // { $set: { a: 5 } }
|
|
1967
1967
|
*
|
|
1968
|
-
* @return {
|
|
1968
|
+
* @return {object} current update operations
|
|
1969
1969
|
* @api public
|
|
1970
1970
|
*/
|
|
1971
1971
|
|
|
@@ -1983,7 +1983,7 @@ Query.prototype.getUpdate = function() {
|
|
|
1983
1983
|
* query.setUpdate({ $set: { b: 6 } });
|
|
1984
1984
|
* query.getUpdate(); // { $set: { b: 6 } }
|
|
1985
1985
|
*
|
|
1986
|
-
* @param {
|
|
1986
|
+
* @param {object} new update operation
|
|
1987
1987
|
* @return {undefined}
|
|
1988
1988
|
* @api public
|
|
1989
1989
|
*/
|
|
@@ -1996,7 +1996,7 @@ Query.prototype.setUpdate = function(val) {
|
|
|
1996
1996
|
* Returns fields selection for this query.
|
|
1997
1997
|
*
|
|
1998
1998
|
* @method _fieldsForExec
|
|
1999
|
-
* @return {
|
|
1999
|
+
* @return {object}
|
|
2000
2000
|
* @api private
|
|
2001
2001
|
* @memberOf Query
|
|
2002
2002
|
*/
|
|
@@ -2016,7 +2016,7 @@ Query.prototype._fieldsForExec = function() {
|
|
|
2016
2016
|
* Return an update document with corrected `$set` operations.
|
|
2017
2017
|
*
|
|
2018
2018
|
* @method _updateForExec
|
|
2019
|
-
* @return {
|
|
2019
|
+
* @return {object}
|
|
2020
2020
|
* @api private
|
|
2021
2021
|
* @memberOf Query
|
|
2022
2022
|
*/
|
|
@@ -2063,7 +2063,7 @@ Query.prototype._updateForExec = function() {
|
|
|
2063
2063
|
* This method is inherited by `mquery`
|
|
2064
2064
|
*
|
|
2065
2065
|
* @method _ensurePath
|
|
2066
|
-
* @param {
|
|
2066
|
+
* @param {string} method
|
|
2067
2067
|
* @api private
|
|
2068
2068
|
* @memberOf Query
|
|
2069
2069
|
*/
|
|
@@ -2074,8 +2074,8 @@ Query.prototype._updateForExec = function() {
|
|
|
2074
2074
|
* @method canMerge
|
|
2075
2075
|
* @memberOf Query
|
|
2076
2076
|
* @instance
|
|
2077
|
-
* @param {
|
|
2078
|
-
* @return {
|
|
2077
|
+
* @param {object} conds
|
|
2078
|
+
* @return {boolean}
|
|
2079
2079
|
* @api private
|
|
2080
2080
|
*/
|
|
2081
2081
|
|
|
@@ -2188,7 +2188,7 @@ Query.prototype._optionsForExec = function(model) {
|
|
|
2188
2188
|
* - [mongoose-lean-getters](https://plugins.mongoosejs.io/plugins/lean-getters)
|
|
2189
2189
|
* - [mongoose-lean-defaults](https://www.npmjs.com/package/mongoose-lean-defaults)
|
|
2190
2190
|
*
|
|
2191
|
-
* @param {
|
|
2191
|
+
* @param {boolean|object} bool defaults to true
|
|
2192
2192
|
* @return {Query} this
|
|
2193
2193
|
* @api public
|
|
2194
2194
|
*/
|
|
@@ -2209,8 +2209,8 @@ Query.prototype.lean = function(v) {
|
|
|
2209
2209
|
* new Query().updateOne({}, {}).set('updatedAt', new Date());
|
|
2210
2210
|
* new Query().updateMany({}, {}).set({ updatedAt: new Date() });
|
|
2211
2211
|
*
|
|
2212
|
-
* @param {
|
|
2213
|
-
* @param {
|
|
2212
|
+
* @param {string|object} path path or object of key/value pairs to set
|
|
2213
|
+
* @param {any} [val] the value to set
|
|
2214
2214
|
* @return {Query} this
|
|
2215
2215
|
* @api public
|
|
2216
2216
|
*/
|
|
@@ -2243,7 +2243,7 @@ Query.prototype.set = function(path, val) {
|
|
|
2243
2243
|
* const query = Model.updateOne({}, { $set: { name: 'Jean-Luc Picard' } });
|
|
2244
2244
|
* query.get('name'); // 'Jean-Luc Picard'
|
|
2245
2245
|
*
|
|
2246
|
-
* @param {
|
|
2246
|
+
* @param {string|object} path path or object of key/value pairs to get
|
|
2247
2247
|
* @return {Query} this
|
|
2248
2248
|
* @api public
|
|
2249
2249
|
*/
|
|
@@ -2338,8 +2338,8 @@ Query.prototype._unsetCastError = function _unsetCastError() {
|
|
|
2338
2338
|
* Mongoose sends `Query.prototype.options` to the MongoDB server, and the
|
|
2339
2339
|
* above options are not relevant for the MongoDB server.
|
|
2340
2340
|
*
|
|
2341
|
-
* @param {
|
|
2342
|
-
* @return {
|
|
2341
|
+
* @param {object} options if specified, overwrites the current options
|
|
2342
|
+
* @return {object} the options
|
|
2343
2343
|
* @api public
|
|
2344
2344
|
*/
|
|
2345
2345
|
|
|
@@ -2482,7 +2482,7 @@ Query.prototype._find = async function _find() {
|
|
|
2482
2482
|
*
|
|
2483
2483
|
* const arr = await Movie.find({ year: { $gte: 1980, $lte: 1989 } });
|
|
2484
2484
|
*
|
|
2485
|
-
* @param {
|
|
2485
|
+
* @param {object|ObjectId} [filter] mongodb filter. If not specified, returns all documents.
|
|
2486
2486
|
* @return {Query} this
|
|
2487
2487
|
* @api public
|
|
2488
2488
|
*/
|
|
@@ -2511,7 +2511,7 @@ Query.prototype.find = function(conditions) {
|
|
|
2511
2511
|
*
|
|
2512
2512
|
* When a Query is passed, conditions, field selection and options are merged.
|
|
2513
2513
|
*
|
|
2514
|
-
* @param {Query|
|
|
2514
|
+
* @param {Query|object} source
|
|
2515
2515
|
* @return {Query} this
|
|
2516
2516
|
*/
|
|
2517
2517
|
|
|
@@ -2602,7 +2602,7 @@ Query.prototype.merge = function(source) {
|
|
|
2602
2602
|
/**
|
|
2603
2603
|
* Adds a collation to this op (MongoDB 3.4 and up)
|
|
2604
2604
|
*
|
|
2605
|
-
* @param {
|
|
2605
|
+
* @param {object} value
|
|
2606
2606
|
* @return {Query} this
|
|
2607
2607
|
* @see MongoDB docs https://www.mongodb.com/docs/manual/reference/method/cursor.collation/#cursor.collation
|
|
2608
2608
|
* @api public
|
|
@@ -2679,9 +2679,9 @@ Query.prototype._completeOne = function(doc, res, projection, callback) {
|
|
|
2679
2679
|
* of the model. Used to initialize docs returned from the db from `find()`
|
|
2680
2680
|
*
|
|
2681
2681
|
* @param {Array} docs
|
|
2682
|
-
* @param {
|
|
2683
|
-
* @param {
|
|
2684
|
-
* @param {
|
|
2682
|
+
* @param {object} fields the projection used, including `select` from schemas
|
|
2683
|
+
* @param {object} userProvidedFields the user-specified projection
|
|
2684
|
+
* @param {object} [opts]
|
|
2685
2685
|
* @param {Array} [opts.populated]
|
|
2686
2686
|
* @param {ClientSession} [opts.session]
|
|
2687
2687
|
* @api private
|
|
@@ -2758,10 +2758,10 @@ Query.prototype._findOne = async function _findOne() {
|
|
|
2758
2758
|
* const query = Kitten.where({ color: 'white' });
|
|
2759
2759
|
* const kitten = await query.findOne();
|
|
2760
2760
|
*
|
|
2761
|
-
* @param {
|
|
2762
|
-
* @param {
|
|
2763
|
-
* @param {
|
|
2764
|
-
* @param {
|
|
2761
|
+
* @param {object} [filter] mongodb selector
|
|
2762
|
+
* @param {object} [projection] optional fields to return
|
|
2763
|
+
* @param {object} [options] see [`setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions())
|
|
2764
|
+
* @param {boolean} [options.translateAliases=null] If set to `true`, translates any schema-defined aliases in `filter`, `projection`, `update`, and `distinct`. Throws an error if there are any conflicts where both alias and raw property are defined on the same object.
|
|
2765
2765
|
* @return {Query} this
|
|
2766
2766
|
* @see findOne https://www.mongodb.com/docs/manual/reference/method/db.collection.findOne/
|
|
2767
2767
|
* @see Query.select https://mongoosejs.com/docs/api/query.html#Query.prototype.select()
|
|
@@ -2892,7 +2892,7 @@ Query.prototype._estimatedDocumentCount = async function _estimatedDocumentCount
|
|
|
2892
2892
|
*
|
|
2893
2893
|
* await Model.find().estimatedDocumentCount();
|
|
2894
2894
|
*
|
|
2895
|
-
* @param {
|
|
2895
|
+
* @param {object} [options] passed transparently to the [MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/EstimatedDocumentCountOptions.html)
|
|
2896
2896
|
* @return {Query} this
|
|
2897
2897
|
* @see estimatedDocumentCount https://mongodb.github.io/node-mongodb-native/4.9/classes/Collection.html#estimatedDocumentCount
|
|
2898
2898
|
* @api public
|
|
@@ -2944,8 +2944,8 @@ Query.prototype.estimatedDocumentCount = function(options) {
|
|
|
2944
2944
|
* - `$near`: [`$geoWithin`](https://www.mongodb.com/docs/manual/reference/operator/query/geoWithin/) with [`$center`](https://www.mongodb.com/docs/manual/reference/operator/query/center/#op._S_center)
|
|
2945
2945
|
* - `$nearSphere`: [`$geoWithin`](https://www.mongodb.com/docs/manual/reference/operator/query/geoWithin/) with [`$centerSphere`](https://www.mongodb.com/docs/manual/reference/operator/query/centerSphere/#op._S_centerSphere)
|
|
2946
2946
|
*
|
|
2947
|
-
* @param {
|
|
2948
|
-
* @param {
|
|
2947
|
+
* @param {object} [filter] mongodb selector
|
|
2948
|
+
* @param {object} [options]
|
|
2949
2949
|
* @return {Query} this
|
|
2950
2950
|
* @see countDocuments https://mongodb.github.io/node-mongodb-native/4.9/classes/Collection.html#countDocuments
|
|
2951
2951
|
* @api public
|
|
@@ -3009,9 +3009,9 @@ Query.prototype.__distinct = async function __distinct() {
|
|
|
3009
3009
|
* distinct(field)
|
|
3010
3010
|
* distinct()
|
|
3011
3011
|
*
|
|
3012
|
-
* @param {
|
|
3013
|
-
* @param {
|
|
3014
|
-
* @param {
|
|
3012
|
+
* @param {string} [field]
|
|
3013
|
+
* @param {object|Query} [filter]
|
|
3014
|
+
* @param {object} [options]
|
|
3015
3015
|
* @return {Query} this
|
|
3016
3016
|
* @see distinct https://www.mongodb.com/docs/manual/reference/method/db.collection.distinct/
|
|
3017
3017
|
* @api public
|
|
@@ -3070,9 +3070,9 @@ Query.prototype.distinct = function(field, conditions, options) {
|
|
|
3070
3070
|
*
|
|
3071
3071
|
* Cannot be used with `distinct()`
|
|
3072
3072
|
*
|
|
3073
|
-
* @param {
|
|
3074
|
-
* @param {
|
|
3075
|
-
* @param {
|
|
3073
|
+
* @param {object|string|Array<Array<(string | number)>>} arg
|
|
3074
|
+
* @param {object} [options]
|
|
3075
|
+
* @param {boolean} [options.override=false] If true, replace existing sort options with `arg`
|
|
3076
3076
|
* @return {Query} this
|
|
3077
3077
|
* @see cursor.sort https://www.mongodb.com/docs/manual/reference/method/cursor.sort/
|
|
3078
3078
|
* @api public
|
|
@@ -3179,9 +3179,9 @@ function _handleSortValue(val, key) {
|
|
|
3179
3179
|
* // `1` if MongoDB deleted a doc, `0` if no docs matched the filter `{ name: ... }`
|
|
3180
3180
|
* res.deletedCount;
|
|
3181
3181
|
*
|
|
3182
|
-
* @param {
|
|
3183
|
-
* @param {
|
|
3184
|
-
* @param {
|
|
3182
|
+
* @param {object|Query} [filter] mongodb selector
|
|
3183
|
+
* @param {object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions())
|
|
3184
|
+
* @param {boolean} [options.requireFilter=false] If true, throws an error if the filter is empty (`{}`)
|
|
3185
3185
|
* @return {Query} this
|
|
3186
3186
|
* @see DeleteResult https://mongodb.github.io/node-mongodb-native/6.15/interfaces/DeleteResult.html
|
|
3187
3187
|
* @see deleteOne https://mongodb.github.io/node-mongodb-native/6.15/classes/Collection.html#deleteOne
|
|
@@ -3255,9 +3255,9 @@ Query.prototype._deleteOne = async function _deleteOne() {
|
|
|
3255
3255
|
* // `0` if no docs matched the filter, number of docs deleted otherwise
|
|
3256
3256
|
* res.deletedCount;
|
|
3257
3257
|
*
|
|
3258
|
-
* @param {
|
|
3259
|
-
* @param {
|
|
3260
|
-
* @param {
|
|
3258
|
+
* @param {object|Query} [filter] mongodb selector
|
|
3259
|
+
* @param {object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions())
|
|
3260
|
+
* @param {boolean} [options.requireFilter=false] If true, throws an error if the filter is empty (`{}`)
|
|
3261
3261
|
* @return {Query} this
|
|
3262
3262
|
* @see DeleteResult https://mongodb.github.io/node-mongodb-native/6.15/interfaces/DeleteResult.html
|
|
3263
3263
|
* @see deleteMany https://mongodb.github.io/node-mongodb-native/6.15/classes/Collection.html#deleteMany
|
|
@@ -3312,8 +3312,8 @@ Query.prototype._deleteMany = async function _deleteMany() {
|
|
|
3312
3312
|
*
|
|
3313
3313
|
* @param {Model} model
|
|
3314
3314
|
* @param {Document} doc
|
|
3315
|
-
* @param {
|
|
3316
|
-
* @param {
|
|
3315
|
+
* @param {object} res 3rd parameter to callback
|
|
3316
|
+
* @param {object} fields
|
|
3317
3317
|
* @param {Query} self
|
|
3318
3318
|
* @param {Array} [pop] array of paths used in population
|
|
3319
3319
|
* @param {Function} callback
|
|
@@ -3402,22 +3402,22 @@ function prepareDiscriminatorCriteria(query) {
|
|
|
3402
3402
|
* @method findOneAndUpdate
|
|
3403
3403
|
* @memberOf Query
|
|
3404
3404
|
* @instance
|
|
3405
|
-
* @param {
|
|
3406
|
-
* @param {
|
|
3407
|
-
* @param {
|
|
3408
|
-
* @param {
|
|
3409
|
-
* @param {
|
|
3405
|
+
* @param {object|Query} [filter]
|
|
3406
|
+
* @param {object} [update]
|
|
3407
|
+
* @param {object} [options]
|
|
3408
|
+
* @param {boolean} [options.includeResultMetadata] if true, returns the full [ModifyResult from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html) rather than just the document
|
|
3409
|
+
* @param {boolean|'throw'} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
|
|
3410
3410
|
* @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](https://mongoosejs.com/docs/transactions.html).
|
|
3411
|
-
* @param {
|
|
3412
|
-
* @param {
|
|
3413
|
-
* @param {
|
|
3414
|
-
* @param {
|
|
3415
|
-
* @param {
|
|
3411
|
+
* @param {boolean} [options.multipleCastError] by default, mongoose only returns the first error that occurred in casting the query. Turn on this option to aggregate all the cast errors.
|
|
3412
|
+
* @param {boolean} [options.new=false] By default, `findOneAndUpdate()` returns the document as it was **before** `update` was applied. If you set `new: true`, `findOneAndUpdate()` will instead give you the object after `update` was applied. **Deprecated:** Use `returnDocument: 'after'` instead of `new: true`, or `returnDocument: 'before'` instead of `new: false`.
|
|
3413
|
+
* @param {object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.lean()) and [the Mongoose lean tutorial](https://mongoosejs.com/docs/tutorials/lean.html).
|
|
3414
|
+
* @param {boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set.
|
|
3415
|
+
* @param {boolean} [options.returnOriginal=null] An alias for the `new` option. `returnOriginal: false` is equivalent to `new: true`. **Deprecated:** Use `returnDocument: 'after'` instead of `returnOriginal: false`, or `returnDocument: 'before'` instead of `returnOriginal: true`.
|
|
3416
3416
|
* @param {'before'|'after'} [options.returnDocument='before'] Has two possible values, `'before'` and `'after'`. By default, it will return the document before the update was applied.
|
|
3417
|
-
* @param {
|
|
3418
|
-
* @param {
|
|
3419
|
-
* @param {
|
|
3420
|
-
* @param {
|
|
3417
|
+
* @param {boolean} [options.translateAliases=null] If set to `true`, translates any schema-defined aliases in `filter`, `projection`, `update`, and `distinct`. Throws an error if there are any conflicts where both alias and raw property are defined on the same object.
|
|
3418
|
+
* @param {boolean} [options.overwriteDiscriminatorKey=false] Mongoose removes discriminator key updates from `update` by default, set `overwriteDiscriminatorKey` to `true` to allow updating the discriminator key
|
|
3419
|
+
* @param {boolean} [options.overwriteImmutable=false] Mongoose removes updated immutable properties from `update` by default (excluding $setOnInsert). Set `overwriteImmutable` to `true` to allow updating immutable properties using other update operators.
|
|
3420
|
+
* @param {boolean} [options.requireFilter=false] If true, throws an error if the filter is empty (`{}`)
|
|
3421
3421
|
* @see Tutorial https://mongoosejs.com/docs/tutorials/findoneandupdate.html
|
|
3422
3422
|
* @see findAndModify command https://www.mongodb.com/docs/manual/reference/command/findAndModify/
|
|
3423
3423
|
* @see ModifyResult https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html
|
|
@@ -3601,12 +3601,12 @@ Query.prototype._findOneAndUpdate = async function _findOneAndUpdate() {
|
|
|
3601
3601
|
*
|
|
3602
3602
|
* @method findOneAndDelete
|
|
3603
3603
|
* @memberOf Query
|
|
3604
|
-
* @param {
|
|
3605
|
-
* @param {
|
|
3606
|
-
* @param {
|
|
3607
|
-
* @param {
|
|
3604
|
+
* @param {object} [filter]
|
|
3605
|
+
* @param {object} [options]
|
|
3606
|
+
* @param {boolean} [options.includeResultMetadata] if true, returns the full [ModifyResult from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html) rather than just the document
|
|
3607
|
+
* @param {boolean} [options.requireFilter=false] If true, throws an error if the filter is empty (`{}`)
|
|
3608
3608
|
* @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](https://mongoosejs.com/docs/transactions.html).
|
|
3609
|
-
* @param {
|
|
3609
|
+
* @param {boolean|'throw'} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
|
|
3610
3610
|
* @return {Query} this
|
|
3611
3611
|
* @see findAndModify command https://www.mongodb.com/docs/manual/reference/command/findAndModify/
|
|
3612
3612
|
* @api public
|
|
@@ -3695,21 +3695,21 @@ Query.prototype._findOneAndDelete = async function _findOneAndDelete() {
|
|
|
3695
3695
|
*
|
|
3696
3696
|
* @method findOneAndReplace
|
|
3697
3697
|
* @memberOf Query
|
|
3698
|
-
* @param {
|
|
3699
|
-
* @param {
|
|
3700
|
-
* @param {
|
|
3701
|
-
* @param {
|
|
3698
|
+
* @param {object} [filter]
|
|
3699
|
+
* @param {object} [replacement]
|
|
3700
|
+
* @param {object} [options]
|
|
3701
|
+
* @param {boolean} [options.includeResultMetadata] if true, returns the full [ModifyResult from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html) rather than just the document
|
|
3702
3702
|
* @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](https://mongoosejs.com/docs/transactions.html).
|
|
3703
|
-
* @param {
|
|
3704
|
-
* @param {
|
|
3705
|
-
* @param {
|
|
3703
|
+
* @param {boolean|'throw'} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
|
|
3704
|
+
* @param {boolean} [options.new=false] By default, `findOneAndUpdate()` returns the document as it was **before** `update` was applied. If you set `new: true`, `findOneAndUpdate()` will instead give you the object after `update` was applied. **Deprecated:** Use `returnDocument: 'after'` instead of `new: true`, or `returnDocument: 'before'` instead of `new: false`.
|
|
3705
|
+
* @param {object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.lean()) and [the Mongoose lean tutorial](https://mongoosejs.com/docs/tutorials/lean.html).
|
|
3706
3706
|
* @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](https://mongoosejs.com/docs/transactions.html).
|
|
3707
|
-
* @param {
|
|
3708
|
-
* @param {
|
|
3709
|
-
* @param {
|
|
3707
|
+
* @param {boolean|'throw'} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
|
|
3708
|
+
* @param {boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set.
|
|
3709
|
+
* @param {boolean} [options.returnOriginal=null] An alias for the `new` option. `returnOriginal: false` is equivalent to `new: true`. **Deprecated:** Use `returnDocument: 'after'` instead of `returnOriginal: false`, or `returnDocument: 'before'` instead of `returnOriginal: true`.
|
|
3710
3710
|
* @param {'before'|'after'} [options.returnDocument='before'] Has two possible values, `'before'` and `'after'`. By default, it will return the document before the update was applied.
|
|
3711
|
-
* @param {
|
|
3712
|
-
* @param {
|
|
3711
|
+
* @param {boolean} [options.translateAliases=null] If set to `true`, translates any schema-defined aliases in `filter`, `projection`, `update`, and `distinct`. Throws an error if there are any conflicts where both alias and raw property are defined on the same object.
|
|
3712
|
+
* @param {boolean} [options.requireFilter=false] If true, throws an error if the filter is empty (`{}`)
|
|
3713
3713
|
* @return {Query} this
|
|
3714
3714
|
* @api public
|
|
3715
3715
|
*/
|
|
@@ -3839,10 +3839,10 @@ Query.prototype._findOneAndReplace = async function _findOneAndReplace() {
|
|
|
3839
3839
|
* @method findById
|
|
3840
3840
|
* @memberOf Query
|
|
3841
3841
|
* @instance
|
|
3842
|
-
* @param {
|
|
3843
|
-
* @param {
|
|
3844
|
-
* @param {
|
|
3845
|
-
* @param {
|
|
3842
|
+
* @param {any} id value of `_id` to query by
|
|
3843
|
+
* @param {object} [projection] optional fields to return
|
|
3844
|
+
* @param {object} [options] see [`setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions())
|
|
3845
|
+
* @param {boolean} [options.translateAliases=null] If set to `true`, translates any schema-defined aliases in `projection`, `update`, and `distinct`. Throws an error if there are any conflicts where both alias and raw property are defined on the same object.
|
|
3846
3846
|
* @return {Query} this
|
|
3847
3847
|
* @see findOne https://www.mongodb.com/docs/manual/reference/method/db.collection.findOne/
|
|
3848
3848
|
* @see Query.select https://mongoosejs.com/docs/api/query.html#Query.prototype.select()
|
|
@@ -3868,21 +3868,21 @@ Query.prototype.findById = function(id, projection, options) {
|
|
|
3868
3868
|
* @method findByIdAndUpdate
|
|
3869
3869
|
* @memberOf Query
|
|
3870
3870
|
* @instance
|
|
3871
|
-
* @param {
|
|
3872
|
-
* @param {
|
|
3873
|
-
* @param {
|
|
3874
|
-
* @param {
|
|
3875
|
-
* @param {
|
|
3871
|
+
* @param {any} id value of `_id` to query by
|
|
3872
|
+
* @param {object} [doc]
|
|
3873
|
+
* @param {object} [options]
|
|
3874
|
+
* @param {boolean} [options.includeResultMetadata] if true, returns the full [ModifyResult from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html) rather than just the document
|
|
3875
|
+
* @param {boolean|'throw'} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
|
|
3876
3876
|
* @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](https://mongoosejs.com/docs/transactions.html).
|
|
3877
|
-
* @param {
|
|
3878
|
-
* @param {
|
|
3879
|
-
* @param {
|
|
3880
|
-
* @param {
|
|
3881
|
-
* @param {
|
|
3877
|
+
* @param {boolean} [options.multipleCastError] by default, mongoose only returns the first error that occurred in casting the query. Turn on this option to aggregate all the cast errors.
|
|
3878
|
+
* @param {boolean} [options.new=false] By default, `findOneAndUpdate()` returns the document as it was **before** `update` was applied. If you set `new: true`, `findOneAndUpdate()` will instead give you the object after `update` was applied. **Deprecated:** Use `returnDocument: 'after'` instead of `new: true`, or `returnDocument: 'before'` instead of `new: false`.
|
|
3879
|
+
* @param {object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.lean()) and [the Mongoose lean tutorial](https://mongoosejs.com/docs/tutorials/lean.html).
|
|
3880
|
+
* @param {boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set.
|
|
3881
|
+
* @param {boolean} [options.returnOriginal=null] An alias for the `new` option. `returnOriginal: false` is equivalent to `new: true`. **Deprecated:** Use `returnDocument: 'after'` instead of `returnOriginal: false`, or `returnDocument: 'before'` instead of `returnOriginal: true`.
|
|
3882
3882
|
* @param {'before'|'after'} [options.returnDocument='before'] Has two possible values, `'before'` and `'after'`. By default, it will return the document before the update was applied.
|
|
3883
|
-
* @param {
|
|
3884
|
-
* @param {
|
|
3885
|
-
* @param {
|
|
3883
|
+
* @param {boolean} [options.translateAliases=null] If set to `true`, translates any schema-defined aliases in `projection`, `update`, and `distinct`. Throws an error if there are any conflicts where both alias and raw property are defined on the same object.
|
|
3884
|
+
* @param {boolean} [options.overwriteDiscriminatorKey=false] Mongoose removes discriminator key updates from `update` by default, set `overwriteDiscriminatorKey` to `true` to allow updating the discriminator key
|
|
3885
|
+
* @param {boolean} [options.overwriteImmutable=false] Mongoose removes updated immutable properties from `update` by default (excluding $setOnInsert). Set `overwriteImmutable` to `true` to allow updating immutable properties using other update operators.
|
|
3886
3886
|
* @see Tutorial https://mongoosejs.com/docs/tutorials/findoneandupdate.html
|
|
3887
3887
|
* @see findAndModify command https://www.mongodb.com/docs/manual/reference/command/findAndModify/
|
|
3888
3888
|
* @see ModifyResult https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html
|
|
@@ -3907,10 +3907,10 @@ Query.prototype.findByIdAndUpdate = function(id, update, options) {
|
|
|
3907
3907
|
* @method findByIdAndDelete
|
|
3908
3908
|
* @memberOf Query
|
|
3909
3909
|
* @param {any} id value of `_id` to query by
|
|
3910
|
-
* @param {
|
|
3911
|
-
* @param {
|
|
3910
|
+
* @param {object} [options]
|
|
3911
|
+
* @param {boolean} [options.includeResultMetadata] if true, returns the full [ModifyResult from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html) rather than just the document
|
|
3912
3912
|
* @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](https://mongoosejs.com/docs/transactions.html).
|
|
3913
|
-
* @param {
|
|
3913
|
+
* @param {boolean|'throw'} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
|
|
3914
3914
|
* @return {Query} this
|
|
3915
3915
|
* @see findAndModify command https://www.mongodb.com/docs/manual/reference/command/findAndModify/
|
|
3916
3916
|
* @api public
|
|
@@ -3954,8 +3954,8 @@ function convertNewToReturnDocument(options) {
|
|
|
3954
3954
|
/**
|
|
3955
3955
|
* Get options from query opts, falling back to the base mongoose object.
|
|
3956
3956
|
* @param {Query} query
|
|
3957
|
-
* @param {
|
|
3958
|
-
* @param {
|
|
3957
|
+
* @param {object} option
|
|
3958
|
+
* @param {any} def
|
|
3959
3959
|
* @api private
|
|
3960
3960
|
*/
|
|
3961
3961
|
|
|
@@ -4038,7 +4038,7 @@ function _completeManyLean(schema, docs, path, opts) {
|
|
|
4038
4038
|
* Override mquery.prototype._mergeUpdate to handle mongoose objects in
|
|
4039
4039
|
* updates.
|
|
4040
4040
|
*
|
|
4041
|
-
* @param {
|
|
4041
|
+
* @param {object} update
|
|
4042
4042
|
* @method _mergeUpdate
|
|
4043
4043
|
* @memberOf Query
|
|
4044
4044
|
* @instance
|
|
@@ -4158,9 +4158,9 @@ async function _updateThunk(op) {
|
|
|
4158
4158
|
* Mongoose calls this function internally to validate the query if
|
|
4159
4159
|
* `runValidators` is set
|
|
4160
4160
|
*
|
|
4161
|
-
* @param {
|
|
4162
|
-
* @param {
|
|
4163
|
-
* @param {
|
|
4161
|
+
* @param {object} castedDoc the update, after casting
|
|
4162
|
+
* @param {object} options the options from `_optionsForExec()`
|
|
4163
|
+
* @param {boolean} isOverwriting
|
|
4164
4164
|
* @method validate
|
|
4165
4165
|
* @memberOf Query
|
|
4166
4166
|
* @instance
|
|
@@ -4243,18 +4243,18 @@ Query.prototype._replaceOne = async function _replaceOne() {
|
|
|
4243
4243
|
*
|
|
4244
4244
|
* - `updateMany()`
|
|
4245
4245
|
*
|
|
4246
|
-
* @param {
|
|
4247
|
-
* @param {
|
|
4248
|
-
* @param {
|
|
4249
|
-
* @param {
|
|
4250
|
-
* @param {
|
|
4251
|
-
* @param {
|
|
4252
|
-
* @param {
|
|
4253
|
-
* @param {
|
|
4254
|
-
* @param {
|
|
4255
|
-
* @param {
|
|
4256
|
-
* @param {
|
|
4257
|
-
* @param {
|
|
4246
|
+
* @param {object} [filter]
|
|
4247
|
+
* @param {object|Array} [update] the update command. If array, this update will be treated as an update pipeline and not casted.
|
|
4248
|
+
* @param {object} [options]
|
|
4249
|
+
* @param {boolean} [options.multipleCastError] by default, mongoose only returns the first error that occurred in casting the query. Turn on this option to aggregate all the cast errors.
|
|
4250
|
+
* @param {boolean|'throw'} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
|
|
4251
|
+
* @param {boolean} [options.upsert=false] if true, and no documents found, insert a new document
|
|
4252
|
+
* @param {object} [options.writeConcern=null] sets the [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/) for replica sets. Overrides the [schema-level write concern](https://mongoosejs.com/docs/guide.html#writeConcern)
|
|
4253
|
+
* @param {boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Does nothing if schema-level timestamps are not set.
|
|
4254
|
+
* @param {boolean} [options.translateAliases=null] If set to `true`, translates any schema-defined aliases in `filter`, `projection`, `update`, and `distinct`. Throws an error if there are any conflicts where both alias and raw property are defined on the same object.
|
|
4255
|
+
* @param {boolean} [options.overwriteDiscriminatorKey=false] Mongoose removes discriminator key updates from `update` by default, set `overwriteDiscriminatorKey` to `true` to allow updating the discriminator key
|
|
4256
|
+
* @param {boolean} [options.overwriteImmutable=false] Mongoose removes updated immutable properties from `update` by default (excluding $setOnInsert). Set `overwriteImmutable` to `true` to allow updating immutable properties using other update operators.
|
|
4257
|
+
* @param {boolean} [options.requireFilter=false] If true, throws an error if the filter is empty (`{}`)
|
|
4258
4258
|
* @return {Query} this
|
|
4259
4259
|
* @see Model.update https://mongoosejs.com/docs/api/model.html#Model.update()
|
|
4260
4260
|
* @see Query docs https://mongoosejs.com/docs/queries.html
|
|
@@ -4318,18 +4318,18 @@ Query.prototype.updateMany = function(conditions, doc, options, callback) {
|
|
|
4318
4318
|
*
|
|
4319
4319
|
* - `updateOne()`
|
|
4320
4320
|
*
|
|
4321
|
-
* @param {
|
|
4322
|
-
* @param {
|
|
4323
|
-
* @param {
|
|
4324
|
-
* @param {
|
|
4325
|
-
* @param {
|
|
4326
|
-
* @param {
|
|
4327
|
-
* @param {
|
|
4328
|
-
* @param {
|
|
4329
|
-
* @param {
|
|
4330
|
-
* @param {
|
|
4331
|
-
* @param {
|
|
4332
|
-
* @param {
|
|
4321
|
+
* @param {object} [filter]
|
|
4322
|
+
* @param {object|Array} [update] the update command. If array, this update will be treated as an update pipeline and not casted.
|
|
4323
|
+
* @param {object} [options]
|
|
4324
|
+
* @param {boolean} [options.multipleCastError] by default, mongoose only returns the first error that occurred in casting the query. Turn on this option to aggregate all the cast errors.
|
|
4325
|
+
* @param {boolean|'throw'} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
|
|
4326
|
+
* @param {boolean} [options.upsert=false] if true, and no documents found, insert a new document
|
|
4327
|
+
* @param {object} [options.writeConcern=null] sets the [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/) for replica sets. Overrides the [schema-level write concern](https://mongoosejs.com/docs/guide.html#writeConcern)
|
|
4328
|
+
* @param {boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set.
|
|
4329
|
+
* @param {boolean} [options.translateAliases=null] If set to `true`, translates any schema-defined aliases in `filter`, `projection`, `update`, and `distinct`. Throws an error if there are any conflicts where both alias and raw property are defined on the same object.
|
|
4330
|
+
* @param {boolean} [options.overwriteDiscriminatorKey=false] Mongoose removes discriminator key updates from `update` by default, set `overwriteDiscriminatorKey` to `true` to allow updating the discriminator key
|
|
4331
|
+
* @param {boolean} [options.overwriteImmutable=false] Mongoose removes updated immutable properties from `update` by default (excluding $setOnInsert). Set `overwriteImmutable` to `true` to allow updating immutable properties using other update operators.
|
|
4332
|
+
* @param {boolean} [options.requireFilter=false] If true, throws an error if the filter is empty (`{}`)
|
|
4333
4333
|
* @return {Query} this
|
|
4334
4334
|
* @see Model.update https://mongoosejs.com/docs/api/model.html#Model.update()
|
|
4335
4335
|
* @see Query docs https://mongoosejs.com/docs/queries.html
|
|
@@ -4387,16 +4387,16 @@ Query.prototype.updateOne = function(conditions, doc, options, callback) {
|
|
|
4387
4387
|
*
|
|
4388
4388
|
* - `replaceOne()`
|
|
4389
4389
|
*
|
|
4390
|
-
* @param {
|
|
4391
|
-
* @param {
|
|
4392
|
-
* @param {
|
|
4393
|
-
* @param {
|
|
4394
|
-
* @param {
|
|
4395
|
-
* @param {
|
|
4396
|
-
* @param {
|
|
4397
|
-
* @param {
|
|
4398
|
-
* @param {
|
|
4399
|
-
* @param {
|
|
4390
|
+
* @param {object} [filter]
|
|
4391
|
+
* @param {object} [doc] the update command
|
|
4392
|
+
* @param {object} [options]
|
|
4393
|
+
* @param {boolean} [options.multipleCastError] by default, mongoose only returns the first error that occurred in casting the query. Turn on this option to aggregate all the cast errors.
|
|
4394
|
+
* @param {boolean|'throw'} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
|
|
4395
|
+
* @param {boolean} [options.upsert=false] if true, and no documents found, insert a new document
|
|
4396
|
+
* @param {object} [options.writeConcern=null] sets the [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/) for replica sets. Overrides the [schema-level write concern](https://mongoosejs.com/docs/guide.html#writeConcern)
|
|
4397
|
+
* @param {boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Does nothing if schema-level timestamps are not set.
|
|
4398
|
+
* @param {boolean} [options.translateAliases=null] If set to `true`, translates any schema-defined aliases in `filter`, `projection`, `update`, and `distinct`. Throws an error if there are any conflicts where both alias and raw property are defined on the same object.
|
|
4399
|
+
* @param {boolean} [options.requireFilter=false] If true, throws an error if the filter is empty (`{}`)
|
|
4400
4400
|
* @return {Query} this
|
|
4401
4401
|
* @see Model.update https://mongoosejs.com/docs/api/model.html#Model.update()
|
|
4402
4402
|
* @see Query docs https://mongoosejs.com/docs/queries.html
|
|
@@ -4437,10 +4437,10 @@ Query.prototype.replaceOne = function(conditions, doc, options, callback) {
|
|
|
4437
4437
|
/**
|
|
4438
4438
|
* Internal helper for update, updateMany, updateOne, replaceOne
|
|
4439
4439
|
* @param {Query} query
|
|
4440
|
-
* @param {
|
|
4441
|
-
* @param {
|
|
4440
|
+
* @param {string} op
|
|
4441
|
+
* @param {object} filter
|
|
4442
4442
|
* @param {Document} [doc]
|
|
4443
|
-
* @param {
|
|
4443
|
+
* @param {object} [options]
|
|
4444
4444
|
* @param {Function} callback
|
|
4445
4445
|
* @api private
|
|
4446
4446
|
*/
|
|
@@ -4611,8 +4611,8 @@ function _orFailError(err, query) {
|
|
|
4611
4611
|
|
|
4612
4612
|
/**
|
|
4613
4613
|
* Wrapper function to call isPathSelectedInclusive on a query.
|
|
4614
|
-
* @param {
|
|
4615
|
-
* @return {
|
|
4614
|
+
* @param {string} path
|
|
4615
|
+
* @return {boolean}
|
|
4616
4616
|
* @api public
|
|
4617
4617
|
*/
|
|
4618
4618
|
|
|
@@ -4628,7 +4628,7 @@ Query.prototype.isPathSelectedInclusive = function(path) {
|
|
|
4628
4628
|
* const promise = query.exec();
|
|
4629
4629
|
* const promise = query.exec('update');
|
|
4630
4630
|
*
|
|
4631
|
-
* @param {
|
|
4631
|
+
* @param {string|Function} [operation]
|
|
4632
4632
|
* @return {Promise}
|
|
4633
4633
|
* @api public
|
|
4634
4634
|
*/
|
|
@@ -4806,7 +4806,7 @@ Query.prototype.finally = function(onFinally) {
|
|
|
4806
4806
|
* const q = Model.find();
|
|
4807
4807
|
* console.log(q); // Prints "Query { find }"
|
|
4808
4808
|
*
|
|
4809
|
-
* @return {
|
|
4809
|
+
* @return {string}
|
|
4810
4810
|
* @api public
|
|
4811
4811
|
* @method [Symbol.toStringTag]
|
|
4812
4812
|
* @memberOf Query
|
|
@@ -4871,8 +4871,8 @@ Query.prototype.post = function(fn) {
|
|
|
4871
4871
|
/**
|
|
4872
4872
|
* Casts obj for an update command.
|
|
4873
4873
|
*
|
|
4874
|
-
* @param {
|
|
4875
|
-
* @return {
|
|
4874
|
+
* @param {object} obj
|
|
4875
|
+
* @return {object} obj after casting its values
|
|
4876
4876
|
* @method _castUpdate
|
|
4877
4877
|
* @memberOf Query
|
|
4878
4878
|
* @instance
|
|
@@ -4942,18 +4942,18 @@ Query.prototype._castUpdate = function _castUpdate(obj) {
|
|
|
4942
4942
|
* a response for each query has also been returned, the results are passed to
|
|
4943
4943
|
* the callback.
|
|
4944
4944
|
*
|
|
4945
|
-
* @param {
|
|
4946
|
-
* @param {
|
|
4945
|
+
* @param {object|string|Array<string>} path either the path(s) to populate or an object specifying all parameters
|
|
4946
|
+
* @param {object|string} [select] Field selection for the population query
|
|
4947
4947
|
* @param {Model} [model] The model you wish to use for population. If not specified, populate will look up the model by the name in the Schema's `ref` field.
|
|
4948
|
-
* @param {
|
|
4949
|
-
* @param {
|
|
4950
|
-
* @param {
|
|
4948
|
+
* @param {object} [match] Conditions for the population query
|
|
4949
|
+
* @param {object} [options] Options for the population query (sort, etc)
|
|
4950
|
+
* @param {string} [options.path=null] The path to populate.
|
|
4951
4951
|
* @param {boolean} [options.retainNullValues=false] by default, Mongoose removes null and undefined values from populated arrays. Use this option to make `populate()` retain `null` and `undefined` array entries.
|
|
4952
4952
|
* @param {boolean} [options.getters=false] if true, Mongoose will call any getters defined on the `localField`. By default, Mongoose gets the raw value of `localField`. For example, you would need to set this option to `true` if you wanted to [add a `lowercase` getter to your `localField`](https://mongoosejs.com/docs/schematypes.html#schematype-options).
|
|
4953
4953
|
* @param {boolean} [options.clone=false] When you do `BlogPost.find().populate('author')`, blog posts with the same author will share 1 copy of an `author` doc. Enable this option to make Mongoose clone populated docs before assigning them.
|
|
4954
|
-
* @param {
|
|
4954
|
+
* @param {object|Function} [options.match=null] Add an additional filter to the populate query. Can be a filter object containing [MongoDB query syntax](https://www.mongodb.com/docs/manual/tutorial/query-documents/), or a function that returns a filter object.
|
|
4955
4955
|
* @param {Function} [options.transform=null] Function that Mongoose will call on every populated document that allows you to transform the populated document.
|
|
4956
|
-
* @param {
|
|
4956
|
+
* @param {object} [options.options=null] Additional options like `limit` and `lean`.
|
|
4957
4957
|
* @see population https://mongoosejs.com/docs/populate.html
|
|
4958
4958
|
* @see Query#select https://mongoosejs.com/docs/api/query.html#Query.prototype.select()
|
|
4959
4959
|
* @see Model.populate https://mongoosejs.com/docs/api/model.html#Model.populate()
|
|
@@ -5057,8 +5057,8 @@ function _getPopulatedPaths(list, arr, prefix) {
|
|
|
5057
5057
|
* If `obj` is present, it is cast instead of this query.
|
|
5058
5058
|
*
|
|
5059
5059
|
* @param {Model} [model] the model to cast to. If not set, defaults to `this.model`
|
|
5060
|
-
* @param {
|
|
5061
|
-
* @return {
|
|
5060
|
+
* @param {object} [obj]
|
|
5061
|
+
* @return {object}
|
|
5062
5062
|
* @api public
|
|
5063
5063
|
*/
|
|
5064
5064
|
|
|
@@ -5100,7 +5100,7 @@ Query.prototype.cast = function(model, obj) {
|
|
|
5100
5100
|
*
|
|
5101
5101
|
* query.select({ ids: { $elemMatch: { $in: [hexString] }})
|
|
5102
5102
|
*
|
|
5103
|
-
* @param {
|
|
5103
|
+
* @param {object} fields
|
|
5104
5104
|
* @see https://github.com/Automattic/mongoose/issues/1091
|
|
5105
5105
|
* @see https://www.mongodb.com/docs/manual/reference/projection/elemMatch/
|
|
5106
5106
|
* @api private
|
|
@@ -5221,7 +5221,7 @@ Query.prototype._applyPaths = function applyPaths() {
|
|
|
5221
5221
|
* - `transform`: optional function which accepts a mongoose document. The return value of the function will be emitted on `data` and returned by `.next()`.
|
|
5222
5222
|
*
|
|
5223
5223
|
* @return {QueryCursor}
|
|
5224
|
-
* @param {
|
|
5224
|
+
* @param {object} [options]
|
|
5225
5225
|
* @see QueryCursor https://mongoosejs.com/docs/api/querycursor.html
|
|
5226
5226
|
* @api public
|
|
5227
5227
|
*/
|
|
@@ -5258,10 +5258,10 @@ Query.prototype.cursor = function cursor(opts) {
|
|
|
5258
5258
|
*
|
|
5259
5259
|
* Cannot be used with `distinct()`
|
|
5260
5260
|
*
|
|
5261
|
-
* @param {
|
|
5262
|
-
* @param {
|
|
5263
|
-
* @param {
|
|
5264
|
-
* @param {
|
|
5261
|
+
* @param {boolean} bool defaults to true
|
|
5262
|
+
* @param {object} [opts] options to set
|
|
5263
|
+
* @param {boolean} [opts.awaitData] false by default. Set to true to keep the cursor open even if there's no data.
|
|
5264
|
+
* @param {number} [opts.maxAwaitTimeMS] the maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query. Requires `tailable` and `awaitData` to be true
|
|
5265
5265
|
* @see tailable https://www.mongodb.com/docs/manual/tutorial/create-tailable-cursor/
|
|
5266
5266
|
* @api public
|
|
5267
5267
|
*/
|
|
@@ -5320,7 +5320,7 @@ Query.prototype.tailable = function(val, opts) {
|
|
|
5320
5320
|
* @method intersects
|
|
5321
5321
|
* @memberOf Query
|
|
5322
5322
|
* @instance
|
|
5323
|
-
* @param {
|
|
5323
|
+
* @param {object} [arg]
|
|
5324
5324
|
* @return {Query} this
|
|
5325
5325
|
* @see $geometry https://www.mongodb.com/docs/manual/reference/operator/geometry/
|
|
5326
5326
|
* @see geoIntersects https://www.mongodb.com/docs/manual/reference/operator/geoIntersects/
|
|
@@ -5359,7 +5359,7 @@ Query.prototype.tailable = function(val, opts) {
|
|
|
5359
5359
|
* @method geometry
|
|
5360
5360
|
* @memberOf Query
|
|
5361
5361
|
* @instance
|
|
5362
|
-
* @param {
|
|
5362
|
+
* @param {object} object Must contain a `type` property which is a String and a `coordinates` property which is an Array. See the examples.
|
|
5363
5363
|
* @return {Query} this
|
|
5364
5364
|
* @see $geometry https://www.mongodb.com/docs/manual/reference/operator/geometry/
|
|
5365
5365
|
* @see Geospatial Support Enhancements https://www.mongodb.com/docs/manual/release-notes/2.4/#geospatial-support-enhancements
|
|
@@ -5382,8 +5382,8 @@ Query.prototype.tailable = function(val, opts) {
|
|
|
5382
5382
|
* @method near
|
|
5383
5383
|
* @memberOf Query
|
|
5384
5384
|
* @instance
|
|
5385
|
-
* @param {
|
|
5386
|
-
* @param {
|
|
5385
|
+
* @param {string} [path]
|
|
5386
|
+
* @param {object} val
|
|
5387
5387
|
* @return {Query} this
|
|
5388
5388
|
* @see $near https://www.mongodb.com/docs/manual/reference/operator/near/
|
|
5389
5389
|
* @see $nearSphere https://www.mongodb.com/docs/manual/reference/operator/nearSphere/
|
|
@@ -5518,8 +5518,8 @@ Query.prototype[Symbol.asyncIterator] = function queryAsyncIterator() {
|
|
|
5518
5518
|
* @method polygon
|
|
5519
5519
|
* @memberOf Query
|
|
5520
5520
|
* @instance
|
|
5521
|
-
* @param {
|
|
5522
|
-
* @param {...Array|
|
|
5521
|
+
* @param {string|Array} [path]
|
|
5522
|
+
* @param {...Array|object} [coordinatePairs]
|
|
5523
5523
|
* @return {Query} this
|
|
5524
5524
|
* @see $polygon https://www.mongodb.com/docs/manual/reference/operator/polygon/
|
|
5525
5525
|
* @see MongoDB Geospatial Indexing https://www.mongodb.com/docs/manual/core/geospatial-indexes/
|
|
@@ -5543,8 +5543,8 @@ Query.prototype[Symbol.asyncIterator] = function queryAsyncIterator() {
|
|
|
5543
5543
|
* @see $box https://www.mongodb.com/docs/manual/reference/operator/box/
|
|
5544
5544
|
* @see within() Query#within https://mongoosejs.com/docs/api/query.html#Query.prototype.within()
|
|
5545
5545
|
* @see MongoDB Geospatial Indexing https://www.mongodb.com/docs/manual/core/geospatial-indexes/
|
|
5546
|
-
* @param {
|
|
5547
|
-
* @param {Array<
|
|
5546
|
+
* @param {object|Array<number>} val1 Lower Left Coordinates OR a object of lower-left(ll) and upper-right(ur) Coordinates
|
|
5547
|
+
* @param {Array<number>} [val2] Upper Right Coordinates
|
|
5548
5548
|
* @return {Query} this
|
|
5549
5549
|
* @api public
|
|
5550
5550
|
*/
|
|
@@ -5587,8 +5587,8 @@ Query.prototype.box = function(ll, ur) {
|
|
|
5587
5587
|
* @method circle
|
|
5588
5588
|
* @memberOf Query
|
|
5589
5589
|
* @instance
|
|
5590
|
-
* @param {
|
|
5591
|
-
* @param {
|
|
5590
|
+
* @param {string} [path]
|
|
5591
|
+
* @param {object} area
|
|
5592
5592
|
* @return {Query} this
|
|
5593
5593
|
* @see $center https://www.mongodb.com/docs/manual/reference/operator/center/
|
|
5594
5594
|
* @see $centerSphere https://www.mongodb.com/docs/manual/reference/operator/centerSphere/
|
|
@@ -5622,8 +5622,8 @@ Query.prototype.center = Query.base.circle;
|
|
|
5622
5622
|
* query.where('loc').within().centerSphere(area);
|
|
5623
5623
|
*
|
|
5624
5624
|
* @deprecated
|
|
5625
|
-
* @param {
|
|
5626
|
-
* @param {
|
|
5625
|
+
* @param {string} [path]
|
|
5626
|
+
* @param {object} val
|
|
5627
5627
|
* @return {Query} this
|
|
5628
5628
|
* @see MongoDB Geospatial Indexing https://www.mongodb.com/docs/manual/core/geospatial-indexes/
|
|
5629
5629
|
* @see $centerSphere https://www.mongodb.com/docs/manual/reference/operator/centerSphere/
|
|
@@ -5648,7 +5648,7 @@ Query.prototype.centerSphere = function() {
|
|
|
5648
5648
|
* @method selected
|
|
5649
5649
|
* @memberOf Query
|
|
5650
5650
|
* @instance
|
|
5651
|
-
* @return {
|
|
5651
|
+
* @return {boolean}
|
|
5652
5652
|
* @api public
|
|
5653
5653
|
*/
|
|
5654
5654
|
|
|
@@ -5662,7 +5662,7 @@ Query.prototype.centerSphere = function() {
|
|
|
5662
5662
|
* @method selectedInclusively
|
|
5663
5663
|
* @memberOf Query
|
|
5664
5664
|
* @instance
|
|
5665
|
-
* @return {
|
|
5665
|
+
* @return {boolean}
|
|
5666
5666
|
* @api public
|
|
5667
5667
|
*/
|
|
5668
5668
|
|
|
@@ -5681,7 +5681,7 @@ Query.prototype.selectedInclusively = function selectedInclusively() {
|
|
|
5681
5681
|
* @method selectedExclusively
|
|
5682
5682
|
* @memberOf Query
|
|
5683
5683
|
* @instance
|
|
5684
|
-
* @return {
|
|
5684
|
+
* @return {boolean}
|
|
5685
5685
|
* @api public
|
|
5686
5686
|
*/
|
|
5687
5687
|
|