mongoose 6.9.0 → 6.9.2

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/query.js CHANGED
@@ -70,7 +70,7 @@ const queryOptionMethods = new Set([
70
70
  /**
71
71
  * Query constructor used for building queries. You do not need
72
72
  * to instantiate a `Query` directly. Instead use Model functions like
73
- * [`Model.find()`](/docs/api/find.html#find_find).
73
+ * [`Model.find()`](/docs/api/model.html#model_Model-find).
74
74
  *
75
75
  * #### Example:
76
76
  *
@@ -166,7 +166,7 @@ Query.base = mquery.prototype;
166
166
  *
167
167
  * MongoDB 2.4 deprecated the use of `$within`, replacing it with `$geoWithin`. Mongoose uses `$geoWithin` by default (which is 100% backward compatible with `$within`). If you are running an older version of MongoDB, set this flag to `false` so your `within()` queries continue to work.
168
168
  *
169
- * @see geoWithin https://docs.mongodb.org/manual/reference/operator/geoWithin/
169
+ * @see geoWithin https://www.mongodb.com/docs/manual/reference/operator/geoWithin/
170
170
  * @default true
171
171
  * @property use$geoWithin
172
172
  * @memberOf Query
@@ -323,9 +323,9 @@ Query.prototype.clone = function clone() {
323
323
  * #### Note:
324
324
  *
325
325
  * Only use `$where` when you have a condition that cannot be met using other MongoDB operators like `$lt`.
326
- * **Be sure to read about all of [its caveats](https://docs.mongodb.org/manual/reference/operator/where/) before using.**
326
+ * **Be sure to read about all of [its caveats](https://www.mongodb.com/docs/manual/reference/operator/where/) before using.**
327
327
  *
328
- * @see $where https://docs.mongodb.org/manual/reference/operator/where/
328
+ * @see $where https://www.mongodb.com/docs/manual/reference/operator/where/
329
329
  * @method $where
330
330
  * @param {String|Function} js javascript string or function
331
331
  * @return {Query} this
@@ -398,8 +398,8 @@ Query.prototype.clone = function clone() {
398
398
  * @param {String} [path]
399
399
  * @param {Number|Array} val number of elements to slice or array with number of elements to skip and number of elements to slice
400
400
  * @return {Query} this
401
- * @see mongodb https://www.mongodb.org/display/DOCS/Retrieving+a+Subset+of+Fields#RetrievingaSubsetofFields-RetrievingaSubrangeofArrayElements
402
- * @see $slice https://docs.mongodb.org/manual/reference/projection/slice/#prj._S_slice
401
+ * @see mongodb https://www.mongodb.com/docs/manual/tutorial/query-documents/#projection
402
+ * @see $slice https://www.mongodb.com/docs/manual/reference/projection/slice/#prj._S_slice
403
403
  * @api public
404
404
  */
405
405
 
@@ -485,7 +485,7 @@ Query.prototype._validateOp = function() {
485
485
  *
486
486
  * query.or([{ color: 'red' }, { status: 'emergency' }]);
487
487
  *
488
- * @see $or https://docs.mongodb.org/manual/reference/operator/or/
488
+ * @see $or https://www.mongodb.com/docs/manual/reference/operator/or/
489
489
  * @method or
490
490
  * @memberOf Query
491
491
  * @instance
@@ -501,7 +501,7 @@ Query.prototype._validateOp = function() {
501
501
  *
502
502
  * query.nor([{ color: 'green' }, { status: 'ok' }]);
503
503
  *
504
- * @see $nor https://docs.mongodb.org/manual/reference/operator/nor/
504
+ * @see $nor https://www.mongodb.com/docs/manual/reference/operator/nor/
505
505
  * @method nor
506
506
  * @memberOf Query
507
507
  * @instance
@@ -520,7 +520,7 @@ Query.prototype._validateOp = function() {
520
520
  * @method and
521
521
  * @memberOf Query
522
522
  * @instance
523
- * @see $and https://docs.mongodb.org/manual/reference/operator/and/
523
+ * @see $and https://www.mongodb.com/docs/manual/reference/operator/and/
524
524
  * @param {Array} array array of conditions
525
525
  * @return {Query} this
526
526
  * @api public
@@ -543,7 +543,7 @@ Query.prototype._validateOp = function() {
543
543
  * @instance
544
544
  * @param {String} [path]
545
545
  * @param {Number} val
546
- * @see $gt https://docs.mongodb.org/manual/reference/operator/gt/
546
+ * @see $gt https://www.mongodb.com/docs/manual/reference/operator/gt/
547
547
  * @api public
548
548
  */
549
549
 
@@ -557,7 +557,7 @@ Query.prototype._validateOp = function() {
557
557
  * @instance
558
558
  * @param {String} [path]
559
559
  * @param {Number} val
560
- * @see $gte https://docs.mongodb.org/manual/reference/operator/gte/
560
+ * @see $gte https://www.mongodb.com/docs/manual/reference/operator/gte/
561
561
  * @api public
562
562
  */
563
563
 
@@ -571,7 +571,7 @@ Query.prototype._validateOp = function() {
571
571
  * @instance
572
572
  * @param {String} [path]
573
573
  * @param {Number} val
574
- * @see $lt https://docs.mongodb.org/manual/reference/operator/lt/
574
+ * @see $lt https://www.mongodb.com/docs/manual/reference/operator/lt/
575
575
  * @api public
576
576
  */
577
577
 
@@ -581,7 +581,7 @@ Query.prototype._validateOp = function() {
581
581
  * When called with one argument, the most recent path passed to `where()` is used.
582
582
  *
583
583
  * @method lte
584
- * @see $lte https://docs.mongodb.org/manual/reference/operator/lte/
584
+ * @see $lte https://www.mongodb.com/docs/manual/reference/operator/lte/
585
585
  * @memberOf Query
586
586
  * @instance
587
587
  * @param {String} [path]
@@ -594,7 +594,7 @@ Query.prototype._validateOp = function() {
594
594
  *
595
595
  * When called with one argument, the most recent path passed to `where()` is used.
596
596
  *
597
- * @see $ne https://docs.mongodb.org/manual/reference/operator/ne/
597
+ * @see $ne https://www.mongodb.com/docs/manual/reference/operator/ne/
598
598
  * @method ne
599
599
  * @memberOf Query
600
600
  * @instance
@@ -608,7 +608,7 @@ Query.prototype._validateOp = function() {
608
608
  *
609
609
  * When called with one argument, the most recent path passed to `where()` is used.
610
610
  *
611
- * @see $in https://docs.mongodb.org/manual/reference/operator/in/
611
+ * @see $in https://www.mongodb.com/docs/manual/reference/operator/in/
612
612
  * @method in
613
613
  * @memberOf Query
614
614
  * @instance
@@ -622,7 +622,7 @@ Query.prototype._validateOp = function() {
622
622
  *
623
623
  * When called with one argument, the most recent path passed to `where()` is used.
624
624
  *
625
- * @see $nin https://docs.mongodb.org/manual/reference/operator/nin/
625
+ * @see $nin https://www.mongodb.com/docs/manual/reference/operator/nin/
626
626
  * @method nin
627
627
  * @memberOf Query
628
628
  * @instance
@@ -642,7 +642,7 @@ Query.prototype._validateOp = function() {
642
642
  * // Equivalent:
643
643
  * MyModel.find().all('pets', ['dog', 'cat', 'ferret']);
644
644
  *
645
- * @see $all https://docs.mongodb.org/manual/reference/operator/all/
645
+ * @see $all https://www.mongodb.com/docs/manual/reference/operator/all/
646
646
  * @method all
647
647
  * @memberOf Query
648
648
  * @instance
@@ -662,7 +662,7 @@ Query.prototype._validateOp = function() {
662
662
  * assert(Array.isArray(docs));
663
663
  * console.log('documents with 0 tags', docs);
664
664
  *
665
- * @see $size https://docs.mongodb.org/manual/reference/operator/size/
665
+ * @see $size https://www.mongodb.com/docs/manual/reference/operator/size/
666
666
  * @method size
667
667
  * @memberOf Query
668
668
  * @instance
@@ -676,7 +676,7 @@ Query.prototype._validateOp = function() {
676
676
  *
677
677
  * When called with one argument, the most recent path passed to `where()` is used.
678
678
  *
679
- * @see $regex https://docs.mongodb.org/manual/reference/operator/regex/
679
+ * @see $regex https://www.mongodb.com/docs/manual/reference/operator/regex/
680
680
  * @method regex
681
681
  * @memberOf Query
682
682
  * @instance
@@ -690,7 +690,7 @@ Query.prototype._validateOp = function() {
690
690
  *
691
691
  * When called with one argument, the most recent path passed to `where()` is used.
692
692
  *
693
- * @see $maxDistance https://docs.mongodb.org/manual/reference/operator/maxDistance/
693
+ * @see $maxDistance https://www.mongodb.com/docs/manual/reference/operator/maxDistance/
694
694
  * @method maxDistance
695
695
  * @memberOf Query
696
696
  * @instance
@@ -717,7 +717,7 @@ Query.prototype._validateOp = function() {
717
717
  * @param {String} [path]
718
718
  * @param {Array} val must be of length 2, first element is `divisor`, 2nd element is `remainder`.
719
719
  * @return {Query} this
720
- * @see $mod https://docs.mongodb.org/manual/reference/operator/mod/
720
+ * @see $mod https://www.mongodb.com/docs/manual/reference/operator/mod/
721
721
  * @api public
722
722
  */
723
723
 
@@ -766,7 +766,7 @@ Query.prototype.mod = function() {
766
766
  * @param {String} [path]
767
767
  * @param {Boolean} val
768
768
  * @return {Query} this
769
- * @see $exists https://docs.mongodb.org/manual/reference/operator/exists/
769
+ * @see $exists https://www.mongodb.com/docs/manual/reference/operator/exists/
770
770
  * @api public
771
771
  */
772
772
 
@@ -795,7 +795,7 @@ Query.prototype.mod = function() {
795
795
  * @param {String|Object|Function} path
796
796
  * @param {Object|Function} filter
797
797
  * @return {Query} this
798
- * @see $elemMatch https://docs.mongodb.org/manual/reference/operator/elemMatch/
798
+ * @see $elemMatch https://www.mongodb.com/docs/manual/reference/operator/elemMatch/
799
799
  * @api public
800
800
  */
801
801
 
@@ -827,11 +827,11 @@ Query.prototype.mod = function() {
827
827
  * In Mongoose 3.7, `within` changed from a getter to a function. If you need the old syntax, use [this](https://github.com/ebensing/mongoose-within).
828
828
  *
829
829
  * @method within
830
- * @see $polygon https://docs.mongodb.org/manual/reference/operator/polygon/
831
- * @see $box https://docs.mongodb.org/manual/reference/operator/box/
832
- * @see $geometry https://docs.mongodb.org/manual/reference/operator/geometry/
833
- * @see $center https://docs.mongodb.org/manual/reference/operator/center/
834
- * @see $centerSphere https://docs.mongodb.org/manual/reference/operator/centerSphere/
830
+ * @see $polygon https://www.mongodb.com/docs/manual/reference/operator/polygon/
831
+ * @see $box https://www.mongodb.com/docs/manual/reference/operator/box/
832
+ * @see $geometry https://www.mongodb.com/docs/manual/reference/operator/geometry/
833
+ * @see $center https://www.mongodb.com/docs/manual/reference/operator/center/
834
+ * @see $centerSphere https://www.mongodb.com/docs/manual/reference/operator/centerSphere/
835
835
  * @memberOf Query
836
836
  * @instance
837
837
  * @return {Query} this
@@ -886,7 +886,7 @@ Query.prototype.limit = function limit(v) {
886
886
  * @memberOf Query
887
887
  * @instance
888
888
  * @param {Number} val
889
- * @see cursor.skip https://docs.mongodb.org/manual/reference/method/cursor.skip/
889
+ * @see cursor.skip https://www.mongodb.com/docs/manual/reference/method/cursor.skip/
890
890
  * @api public
891
891
  */
892
892
 
@@ -920,7 +920,7 @@ Query.prototype.skip = function skip(v) {
920
920
  * @memberOf Query
921
921
  * @instance
922
922
  * @param {Number} val
923
- * @see maxScan https://docs.mongodb.org/manual/reference/operator/maxScan/
923
+ * @see maxScan https://www.mongodb.com/docs/v4.0/reference/method/cursor.maxScan/
924
924
  * @api public
925
925
  */
926
926
 
@@ -939,7 +939,7 @@ Query.prototype.skip = function skip(v) {
939
939
  * @memberOf Query
940
940
  * @instance
941
941
  * @param {Number} val
942
- * @see batchSize https://docs.mongodb.org/manual/reference/method/cursor.batchSize/
942
+ * @see batchSize https://www.mongodb.com/docs/manual/reference/method/cursor.batchSize/
943
943
  * @api public
944
944
  */
945
945
 
@@ -958,7 +958,7 @@ Query.prototype.skip = function skip(v) {
958
958
  * @memberOf Query
959
959
  * @instance
960
960
  * @param {String} val
961
- * @see comment https://docs.mongodb.org/manual/reference/operator/comment/
961
+ * @see comment https://www.mongodb.com/docs/manual/reference/operator/comment/
962
962
  * @api public
963
963
  */
964
964
 
@@ -978,7 +978,6 @@ Query.prototype.skip = function skip(v) {
978
978
  * @method snapshot
979
979
  * @memberOf Query
980
980
  * @instance
981
- * @see snapshot https://docs.mongodb.org/manual/reference/operator/snapshot/
982
981
  * @return {Query} this
983
982
  * @api public
984
983
  */
@@ -999,7 +998,7 @@ Query.prototype.skip = function skip(v) {
999
998
  * @instance
1000
999
  * @param {Object} val a hint object
1001
1000
  * @return {Query} this
1002
- * @see $hint https://docs.mongodb.org/manual/reference/operator/hint/
1001
+ * @see $hint https://www.mongodb.com/docs/manual/reference/operator/hint/
1003
1002
  * @api public
1004
1003
  */
1005
1004
 
@@ -1051,7 +1050,7 @@ Query.prototype.projection = function(arg) {
1051
1050
  *
1052
1051
  * A projection _must_ be either inclusive or exclusive. In other words, you must
1053
1052
  * either list the fields to include (which excludes all others), or list the fields
1054
- * to exclude (which implies all other fields are included). The [`_id` field is the only exception because MongoDB includes it by default](https://docs.mongodb.com/manual/tutorial/project-fields-from-query-results/#suppress-id-field).
1053
+ * to exclude (which implies all other fields are included). The [`_id` field is the only exception because MongoDB includes it by default](https://www.mongodb.com/docs/manual/tutorial/project-fields-from-query-results/#suppress-id-field).
1055
1054
  *
1056
1055
  * #### Example:
1057
1056
  *
@@ -1088,7 +1087,7 @@ Query.prototype.projection = function(arg) {
1088
1087
  * @instance
1089
1088
  * @param {Object|String|String[]} arg
1090
1089
  * @return {Query} this
1091
- * @see SchemaType /docs/api/schematype
1090
+ * @see SchemaType /docs/api/schematype.html
1092
1091
  * @api public
1093
1092
  */
1094
1093
 
@@ -1207,14 +1206,14 @@ Query.prototype.select = function select() {
1207
1206
  * // read from secondaries with matching tags
1208
1207
  * new Query().read('s', [{ dc:'sf', s: 1 },{ dc:'ma', s: 2 }])
1209
1208
  *
1210
- * Read more about how to use read preferences [here](https://docs.mongodb.org/manual/applications/replication/#read-preference).
1209
+ * Read more about how to use read preferences [here](https://www.mongodb.com/docs/manual/applications/replication/#read-preference).
1211
1210
  *
1212
1211
  * @method read
1213
1212
  * @memberOf Query
1214
1213
  * @instance
1215
1214
  * @param {String} pref one of the listed preference options or aliases
1216
1215
  * @param {Array} [tags] optional tags for this query
1217
- * @see mongodb https://docs.mongodb.org/manual/applications/replication/#read-preference
1216
+ * @see mongodb https://www.mongodb.com/docs/manual/applications/replication/#read-preference
1218
1217
  * @return {Query} this
1219
1218
  * @api public
1220
1219
  */
@@ -1264,7 +1263,7 @@ Query.prototype.toString = function toString() {
1264
1263
  };
1265
1264
 
1266
1265
  /**
1267
- * Sets the [MongoDB session](https://docs.mongodb.com/manual/reference/server-sessions/)
1266
+ * Sets the [MongoDB session](https://www.mongodb.com/docs/manual/reference/server-sessions/)
1268
1267
  * associated with this query. Sessions are how you mark a query as part of a
1269
1268
  * [transaction](/docs/transactions.html).
1270
1269
  *
@@ -1298,7 +1297,7 @@ Query.prototype.session = function session(v) {
1298
1297
  *
1299
1298
  * - `w`: Sets the specified number of `mongod` servers, or tag set of `mongod` servers, that must acknowledge this write before this write is considered successful.
1300
1299
  * - `j`: Boolean, set to `true` to request acknowledgement that this operation has been persisted to MongoDB's on-disk journal.
1301
- * - `wtimeout`: If [`w > 1`](/docs/api/query.html#query_Query-w), the maximum amount of time to wait for this write to propagate through the replica set before this operation fails. The default is `0`, which means no timeout.
1300
+ * - `wtimeout`: If [`w > 1`](#query_Query-w), the maximum amount of time to wait for this write to propagate through the replica set before this operation fails. The default is `0`, which means no timeout.
1302
1301
  *
1303
1302
  * This option is only valid for operations that write to the database:
1304
1303
  *
@@ -1368,8 +1367,8 @@ Query.prototype.writeConcern = function writeConcern(val) {
1368
1367
  * @method w
1369
1368
  * @memberOf Query
1370
1369
  * @instance
1371
- * @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://docs.mongodb.com/manual/reference/write-concern/#w-option).
1372
- * @see mongodb https://docs.mongodb.com/manual/reference/write-concern/#w-option
1370
+ * @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).
1371
+ * @see mongodb https://www.mongodb.com/docs/manual/reference/write-concern/#w-option
1373
1372
  * @return {Query} this
1374
1373
  * @api public
1375
1374
  */
@@ -1411,7 +1410,7 @@ Query.prototype.w = function w(val) {
1411
1410
  * @memberOf Query
1412
1411
  * @instance
1413
1412
  * @param {boolean} val
1414
- * @see mongodb https://docs.mongodb.com/manual/reference/write-concern/#j-option
1413
+ * @see mongodb https://www.mongodb.com/docs/manual/reference/write-concern/#j-option
1415
1414
  * @return {Query} this
1416
1415
  * @api public
1417
1416
  */
@@ -1429,7 +1428,7 @@ Query.prototype.j = function j(val) {
1429
1428
  };
1430
1429
 
1431
1430
  /**
1432
- * If [`w > 1`](/docs/api/query.html#query_Query-w), the maximum amount of time to
1431
+ * If [`w > 1`](#query_Query-w), the maximum amount of time to
1433
1432
  * wait for this write to propagate through the replica set before this
1434
1433
  * operation fails. The default is `0`, which means no timeout.
1435
1434
  *
@@ -1461,7 +1460,7 @@ Query.prototype.j = function j(val) {
1461
1460
  * @memberOf Query
1462
1461
  * @instance
1463
1462
  * @param {number} ms number of milliseconds to wait
1464
- * @see mongodb https://docs.mongodb.com/manual/reference/write-concern/#wtimeout
1463
+ * @see mongodb https://www.mongodb.com/docs/manual/reference/write-concern/#wtimeout
1465
1464
  * @return {Query} this
1466
1465
  * @api public
1467
1466
  */
@@ -1519,12 +1518,12 @@ Query.prototype.wtimeout = function wtimeout(ms) {
1519
1518
  * s snapshot
1520
1519
  * ```
1521
1520
  *
1522
- * Read more about how to use read concern [here](https://docs.mongodb.com/manual/reference/read-concern/).
1521
+ * Read more about how to use read concern [here](https://www.mongodb.com/docs/manual/reference/read-concern/).
1523
1522
  *
1524
1523
  * @memberOf Query
1525
1524
  * @method readConcern
1526
1525
  * @param {String} level one of the listed read concern level or their aliases
1527
- * @see mongodb https://docs.mongodb.com/manual/reference/read-concern/
1526
+ * @see mongodb https://www.mongodb.com/docs/manual/reference/read-concern/
1528
1527
  * @return {Query} this
1529
1528
  * @api public
1530
1529
  */
@@ -1554,35 +1553,35 @@ Query.prototype.getOptions = function() {
1554
1553
  *
1555
1554
  * The following options are only for `find()`:
1556
1555
  *
1557
- * - [tailable](https://www.mongodb.org/display/DOCS/Tailable+Cursors)
1558
- * - [sort](https://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Bsort(\)%7D%7D)
1559
- * - [limit](https://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Blimit%28%29%7D%7D)
1560
- * - [skip](https://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Bskip%28%29%7D%7D)
1561
- * - [allowDiskUse](https://docs.mongodb.com/manual/reference/method/cursor.allowDiskUse/)
1562
- * - [batchSize](https://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7BbatchSize%28%29%7D%7D)
1563
- * - [readPreference](https://docs.mongodb.org/manual/applications/replication/#read-preference)
1564
- * - [hint](https://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24hint)
1565
- * - [comment](https://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24comment)
1566
- * - [snapshot](https://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Bsnapshot%28%29%7D%7D)
1567
- * - [maxscan](https://docs.mongodb.org/v3.2/reference/operator/meta/maxScan/#metaOp._S_maxScan)
1556
+ * - [tailable](https://www.mongodb.com/docs/manual/core/tailable-cursors/)
1557
+ * - [sort](https://www.mongodb.com/docs/manual/reference/method/cursor.sort/)
1558
+ * - [limit](https://www.mongodb.com/docs/manual/reference/method/cursor.limit/)
1559
+ * - [skip](https://www.mongodb.com/docs/manual/reference/method/cursor.skip/)
1560
+ * - [allowDiskUse](https://www.mongodb.com/docs/manual/reference/method/cursor.allowDiskUse/)
1561
+ * - [batchSize](https://www.mongodb.com/docs/manual/reference/method/cursor.batchSize/)
1562
+ * - [readPreference](https://www.mongodb.com/docs/manual/applications/replication/#read-preference)
1563
+ * - [hint](https://www.mongodb.com/docs/manual/reference/method/cursor.hint/)
1564
+ * - [comment](https://www.mongodb.com/docs/manual/reference/method/cursor.comment/)
1565
+ * - snapshot
1566
+ * - [maxscan](https://www.mongodb.com/docs/v4.0/reference/method/cursor.maxScan/)
1568
1567
  *
1569
1568
  * The following options are only for write operations: `update()`, `updateOne()`, `updateMany()`, `replaceOne()`, `findOneAndUpdate()`, and `findByIdAndUpdate()`:
1570
1569
  *
1571
- * - [upsert](https://docs.mongodb.com/manual/reference/method/db.collection.update/)
1572
- * - [writeConcern](https://docs.mongodb.com/manual/reference/method/db.collection.update/)
1570
+ * - [upsert](https://www.mongodb.com/docs/manual/reference/method/db.collection.update/)
1571
+ * - [writeConcern](https://www.mongodb.com/docs/manual/reference/method/db.collection.update/)
1573
1572
  * - [timestamps](https://mongoosejs.com/docs/guide.html#timestamps): If `timestamps` is set in the schema, set this option to `false` to skip timestamps for that particular update. Has no effect if `timestamps` is not enabled in the schema options.
1574
1573
  * - overwriteDiscriminatorKey: allow setting the discriminator key in the update. Will use the correct discriminator schema if the update changes the discriminator key.
1575
1574
  *
1576
1575
  * The following options are only for `find()`, `findOne()`, `findById()`, `findOneAndUpdate()`, and `findByIdAndUpdate()`:
1577
1576
  *
1578
- * - [lean](./api/query.html#query_Query-lean)
1577
+ * - [lean](#query_Query-lean)
1579
1578
  * - [populate](/docs/populate.html)
1580
- * - [projection](/docs/api/query.html#query_Query-projection)
1579
+ * - [projection](#query_Query-projection)
1581
1580
  * - sanitizeProjection
1582
1581
  *
1583
1582
  * The following options are only for all operations **except** `update()`, `updateOne()`, `updateMany()`, `remove()`, `deleteOne()`, and `deleteMany()`:
1584
1583
  *
1585
- * - [maxTimeMS](https://docs.mongodb.com/manual/reference/operator/meta/maxTimeMS/)
1584
+ * - [maxTimeMS](https://www.mongodb.com/docs/manual/reference/operator/meta/maxTimeMS/)
1586
1585
  *
1587
1586
  * The following options are for `findOneAndUpdate()` and `findOneAndRemove()`
1588
1587
  *
@@ -1591,9 +1590,9 @@ Query.prototype.getOptions = function() {
1591
1590
  * The following options are for all operations:
1592
1591
  *
1593
1592
  * - [strict](/docs/guide.html#strict)
1594
- * - [collation](https://docs.mongodb.com/manual/reference/collation/)
1595
- * - [session](https://docs.mongodb.com/manual/reference/server-sessions/)
1596
- * - [explain](https://docs.mongodb.com/manual/reference/method/cursor.explain/)
1593
+ * - [collation](https://www.mongodb.com/docs/manual/reference/collation/)
1594
+ * - [session](https://www.mongodb.com/docs/manual/reference/server-sessions/)
1595
+ * - [explain](https://www.mongodb.com/docs/manual/reference/method/cursor.explain/)
1597
1596
  *
1598
1597
  * @param {Object} options
1599
1598
  * @return {Query} this
@@ -1690,7 +1689,7 @@ Query.prototype.setOptions = function(options, overwrite) {
1690
1689
  };
1691
1690
 
1692
1691
  /**
1693
- * Sets the [`explain` option](https://docs.mongodb.com/manual/reference/method/cursor.explain/),
1692
+ * Sets the [`explain` option](https://www.mongodb.com/docs/manual/reference/method/cursor.explain/),
1694
1693
  * which makes this query return detailed execution stats instead of the actual
1695
1694
  * query result. This method is useful for determining what index your queries
1696
1695
  * use.
@@ -1720,7 +1719,7 @@ Query.prototype.explain = function(verbose) {
1720
1719
  };
1721
1720
 
1722
1721
  /**
1723
- * Sets the [`allowDiskUse` option](https://docs.mongodb.com/manual/reference/method/cursor.allowDiskUse/),
1722
+ * Sets the [`allowDiskUse` option](https://www.mongodb.com/docs/manual/reference/method/cursor.allowDiskUse/),
1724
1723
  * which allows the MongoDB server to use more than 100 MB for this query's `sort()`. This option can
1725
1724
  * let you work around `QueryExceededMemoryLimitNoDiskUseAllowed` errors from the MongoDB server.
1726
1725
  *
@@ -1752,7 +1751,7 @@ Query.prototype.allowDiskUse = function(v) {
1752
1751
  };
1753
1752
 
1754
1753
  /**
1755
- * Sets the [maxTimeMS](https://docs.mongodb.com/manual/reference/method/cursor.maxTimeMS/)
1754
+ * Sets the [maxTimeMS](https://www.mongodb.com/docs/manual/reference/method/cursor.maxTimeMS/)
1756
1755
  * option. This will tell the MongoDB server to abort if the query or write op
1757
1756
  * has been running for more than `ms` milliseconds.
1758
1757
  *
@@ -2004,7 +2003,7 @@ Query.prototype._optionsForExec = function(model) {
2004
2003
  * Sets the lean option.
2005
2004
  *
2006
2005
  * Documents returned from queries with the `lean` option enabled are plain
2007
- * javascript objects, not [Mongoose Documents](/api/document.html). They have no
2006
+ * javascript objects, not [Mongoose Documents](/docs/api/document.html). They have no
2008
2007
  * `save` method, getters/setters, virtuals, or other Mongoose features.
2009
2008
  *
2010
2009
  * #### Example:
@@ -2166,11 +2165,11 @@ Query.prototype._unsetCastError = function _unsetCastError() {
2166
2165
  * Getter/setter around the current mongoose-specific options for this query
2167
2166
  * Below are the current Mongoose-specific options.
2168
2167
  *
2169
- * - `populate`: an array representing what paths will be populated. Should have one entry for each call to [`Query.prototype.populate()`](/docs/api/query.html#query_Query-populate)
2170
- * - `lean`: if truthy, Mongoose will not [hydrate](/docs/api/model.html#model_Model-hydrate) any documents that are returned from this query. See [`Query.prototype.lean()`](/docs/api/query.html#query_Query-lean) for more information.
2168
+ * - `populate`: an array representing what paths will be populated. Should have one entry for each call to [`Query.prototype.populate()`](#query_Query-populate)
2169
+ * - `lean`: if truthy, Mongoose will not [hydrate](/docs/api/model.html#model_Model-hydrate) any documents that are returned from this query. See [`Query.prototype.lean()`](#query_Query-lean) for more information.
2171
2170
  * - `strict`: controls how Mongoose handles keys that aren't in the schema for updates. This option is `true` by default, which means Mongoose will silently strip any paths in the update that aren't in the schema. See the [`strict` mode docs](/docs/guide.html#strict) for more information.
2172
2171
  * - `strictQuery`: controls how Mongoose handles keys that aren't in the schema for the query `filter`. This option is `false` by default for backwards compatibility, which means Mongoose will allow `Model.find({ foo: 'bar' })` even if `foo` is not in the schema. See the [`strictQuery` docs](/docs/guide.html#strictQuery) for more information.
2173
- * - `nearSphere`: use `$nearSphere` instead of `near()`. See the [`Query.prototype.nearSphere()` docs](/docs/api/query.html#query_Query-nearSphere)
2172
+ * - `nearSphere`: use `$nearSphere` instead of `near()`. See the [`Query.prototype.nearSphere()` docs](#query_Query-nearSphere)
2174
2173
  *
2175
2174
  * Mongoose maintains a separate object for internal options because
2176
2175
  * Mongoose sends `Query.prototype.options` to the MongoDB server, and the
@@ -2330,7 +2329,7 @@ Query.prototype._find = wrapThunk(function(callback) {
2330
2329
  * Find all documents that match `selector`. The result will be an array of documents.
2331
2330
  *
2332
2331
  * If there are too many documents in the result to fit in memory, use
2333
- * [`Query.prototype.cursor()`](api/query.html#query_Query-cursor)
2332
+ * [`Query.prototype.cursor()`](#query_Query-cursor)
2334
2333
  *
2335
2334
  * #### Example:
2336
2335
  *
@@ -2436,7 +2435,7 @@ Query.prototype.merge = function(source) {
2436
2435
  *
2437
2436
  * @param {Object} value
2438
2437
  * @return {Query} this
2439
- * @see MongoDB docs https://docs.mongodb.com/manual/reference/method/cursor.collation/#cursor.collation
2438
+ * @see MongoDB docs https://www.mongodb.com/docs/manual/reference/method/cursor.collation/#cursor.collation
2440
2439
  * @api public
2441
2440
  */
2442
2441
 
@@ -2509,7 +2508,7 @@ Query.prototype._completeOne = function(doc, res, callback) {
2509
2508
  * Thunk around findOne()
2510
2509
  *
2511
2510
  * @param {Function} [callback]
2512
- * @see findOne https://docs.mongodb.org/manual/reference/method/db.collection.findOne/
2511
+ * @see findOne https://www.mongodb.com/docs/manual/reference/method/db.collection.findOne/
2513
2512
  * @api private
2514
2513
  */
2515
2514
 
@@ -2563,10 +2562,10 @@ Query.prototype._findOne = wrapThunk(function(callback) {
2563
2562
  *
2564
2563
  * @param {Object} [filter] mongodb selector
2565
2564
  * @param {Object} [projection] optional fields to return
2566
- * @param {Object} [options] see [`setOptions()`](https://mongoosejs.com/docs/api/query.html#query_Query-setOptions)
2565
+ * @param {Object} [options] see [`setOptions()`](#query_Query-setOptions)
2567
2566
  * @param {Function} [callback] optional params are (error, document)
2568
2567
  * @return {Query} this
2569
- * @see findOne https://docs.mongodb.org/manual/reference/method/db.collection.findOne/
2568
+ * @see findOne https://www.mongodb.com/docs/manual/reference/method/db.collection.findOne/
2570
2569
  * @see Query.select #query_Query-select
2571
2570
  * @api public
2572
2571
  */
@@ -2621,7 +2620,7 @@ Query.prototype.findOne = function(conditions, projection, options, callback) {
2621
2620
  * Thunk around count()
2622
2621
  *
2623
2622
  * @param {Function} [callback]
2624
- * @see count https://docs.mongodb.org/manual/reference/method/db.collection.count/
2623
+ * @see count https://www.mongodb.com/docs/manual/reference/method/db.collection.count/
2625
2624
  * @api private
2626
2625
  */
2627
2626
 
@@ -2695,8 +2694,8 @@ Query.prototype._estimatedDocumentCount = wrapThunk(function(callback) {
2695
2694
  * Specifies this query as a `count` query.
2696
2695
  *
2697
2696
  * This method is deprecated. If you want to count the number of documents in
2698
- * a collection, e.g. `count({})`, use the [`estimatedDocumentCount()` function](/docs/api/query.html#query_Query-estimatedDocumentCount)
2699
- * instead. Otherwise, use the [`countDocuments()`](/docs/api/query.html#query_Query-countDocuments) function instead.
2697
+ * a collection, e.g. `count({})`, use the [`estimatedDocumentCount()` function](#query_Query-estimatedDocumentCount)
2698
+ * instead. Otherwise, use the [`countDocuments()`](#query_Query-countDocuments) function instead.
2700
2699
  *
2701
2700
  * Passing a `callback` executes the query.
2702
2701
  *
@@ -2721,7 +2720,7 @@ Query.prototype._estimatedDocumentCount = wrapThunk(function(callback) {
2721
2720
  * @param {Object} [filter] count documents that match this object
2722
2721
  * @param {Function} [callback] optional params are (error, count)
2723
2722
  * @return {Query} this
2724
- * @see count https://docs.mongodb.org/manual/reference/method/db.collection.count/
2723
+ * @see count https://www.mongodb.com/docs/manual/reference/method/db.collection.count/
2725
2724
  * @api public
2726
2725
  */
2727
2726
 
@@ -2825,9 +2824,9 @@ Query.prototype.estimatedDocumentCount = function(options, callback) {
2825
2824
  * Below are the operators that `count()` supports but `countDocuments()` does not,
2826
2825
  * and the suggested replacement:
2827
2826
  *
2828
- * - `$where`: [`$expr`](https://docs.mongodb.com/manual/reference/operator/query/expr/)
2829
- * - `$near`: [`$geoWithin`](https://docs.mongodb.com/manual/reference/operator/query/geoWithin/) with [`$center`](https://docs.mongodb.com/manual/reference/operator/query/center/#op._S_center)
2830
- * - `$nearSphere`: [`$geoWithin`](https://docs.mongodb.com/manual/reference/operator/query/geoWithin/) with [`$centerSphere`](https://docs.mongodb.com/manual/reference/operator/query/centerSphere/#op._S_centerSphere)
2827
+ * - `$where`: [`$expr`](https://www.mongodb.com/docs/manual/reference/operator/query/expr/)
2828
+ * - `$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)
2829
+ * - `$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)
2831
2830
  *
2832
2831
  * @param {Object} [filter] mongodb selector
2833
2832
  * @param {Object} [options]
@@ -2873,7 +2872,7 @@ Query.prototype.countDocuments = function(conditions, options, callback) {
2873
2872
  * Thunk around distinct()
2874
2873
  *
2875
2874
  * @param {Function} [callback]
2876
- * @see distinct https://docs.mongodb.org/manual/reference/method/db.collection.distinct/
2875
+ * @see distinct https://www.mongodb.com/docs/manual/reference/method/db.collection.distinct/
2877
2876
  * @api private
2878
2877
  */
2879
2878
 
@@ -2915,7 +2914,7 @@ Query.prototype.__distinct = wrapThunk(function __distinct(callback) {
2915
2914
  * @param {Object|Query} [filter]
2916
2915
  * @param {Function} [callback] optional params are (error, arr)
2917
2916
  * @return {Query} this
2918
- * @see distinct https://docs.mongodb.org/manual/reference/method/db.collection.distinct/
2917
+ * @see distinct https://www.mongodb.com/docs/manual/reference/method/db.collection.distinct/
2919
2918
  * @api public
2920
2919
  */
2921
2920
 
@@ -2980,7 +2979,7 @@ Query.prototype.distinct = function(field, conditions, callback) {
2980
2979
  *
2981
2980
  * @param {Object|String|Array<Array<(string | number)>>} arg
2982
2981
  * @return {Query} this
2983
- * @see cursor.sort https://docs.mongodb.org/manual/reference/method/cursor.sort/
2982
+ * @see cursor.sort https://www.mongodb.com/docs/manual/reference/method/cursor.sort/
2984
2983
  * @api public
2985
2984
  */
2986
2985
 
@@ -3019,7 +3018,7 @@ Query.prototype.sort = function(arg) {
3019
3018
  *
3020
3019
  * #### Note:
3021
3020
  *
3022
- * Calling `remove()` creates a [Mongoose query](./queries.html), and a query
3021
+ * Calling `remove()` creates a [Mongoose query](/docs/queries.html), and a query
3023
3022
  * does not execute until you either pass a callback, call [`Query#then()`](#query_Query-then),
3024
3023
  * or call [`Query#exec()`](#query_Query-exec).
3025
3024
  *
@@ -3118,7 +3117,7 @@ Query.prototype._remove = wrapThunk(function(callback) {
3118
3117
  * res.deletedCount;
3119
3118
  *
3120
3119
  * @param {Object|Query} [filter] mongodb selector
3121
- * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#query_Query-setOptions)
3120
+ * @param {Object} [options] optional see [`Query.prototype.setOptions()`](#query_Query-setOptions)
3122
3121
  * @param {Function} [callback] optional params are (error, mongooseDeleteResult)
3123
3122
  * @return {Query} this
3124
3123
  * @see DeleteResult https://mongodb.github.io/node-mongodb-native/4.9/interfaces/DeleteResult.html
@@ -3209,7 +3208,7 @@ Query.prototype._deleteOne = wrapThunk(function(callback) {
3209
3208
  * res.deletedCount;
3210
3209
  *
3211
3210
  * @param {Object|Query} [filter] mongodb selector
3212
- * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#query_Query-setOptions)
3211
+ * @param {Object} [options] optional see [`Query.prototype.setOptions()`](#query_Query-setOptions)
3213
3212
  * @param {Function} [callback] optional params are (error, mongooseDeleteResult)
3214
3213
  * @return {Query} this
3215
3214
  * @see DeleteResult https://mongodb.github.io/node-mongodb-native/4.9/interfaces/DeleteResult.html
@@ -3335,7 +3334,7 @@ function prepareDiscriminatorCriteria(query) {
3335
3334
  }
3336
3335
 
3337
3336
  /**
3338
- * Issues a mongodb [findAndModify](https://www.mongodb.org/display/DOCS/findAndModify+Command) update command.
3337
+ * Issues a mongodb [findAndModify](https://www.mongodb.com/docs/manual/reference/command/findAndModify/) update command.
3339
3338
  *
3340
3339
  * Finds a matching document, updates it according to the `update` arg, passing any `options`, and returns the found
3341
3340
  * document (if any) to the callback. The query executes if
@@ -3385,7 +3384,7 @@ function prepareDiscriminatorCriteria(query) {
3385
3384
  * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html).
3386
3385
  * @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.
3387
3386
  * @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.
3388
- * @param {Object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](/docs/api/query.html#query_Query-lean) and [the Mongoose lean tutorial](/docs/tutorials/lean.html).
3387
+ * @param {Object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](#query_Query-lean) and [the Mongoose lean tutorial](/docs/tutorials/lean.html).
3389
3388
  * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html).
3390
3389
  * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
3391
3390
  * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](/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.
@@ -3487,7 +3486,7 @@ Query.prototype._findOneAndUpdate = wrapThunk(function(callback) {
3487
3486
  });
3488
3487
 
3489
3488
  /**
3490
- * Issues a mongodb [findAndModify](https://www.mongodb.org/display/DOCS/findAndModify+Command) remove command.
3489
+ * Issues a mongodb [findAndModify](https://www.mongodb.com/docs/manual/reference/command/findAndModify/) remove command.
3491
3490
  *
3492
3491
  * Finds a matching document, removes it, passing the found document (if any) to
3493
3492
  * the callback. Executes if `callback` is passed.
@@ -3569,7 +3568,7 @@ Query.prototype.findOneAndRemove = function(conditions, options, callback) {
3569
3568
  };
3570
3569
 
3571
3570
  /**
3572
- * Issues a MongoDB [findOneAndDelete](https://docs.mongodb.com/manual/reference/method/db.collection.findOneAndDelete/) command.
3571
+ * Issues a MongoDB [findOneAndDelete](https://www.mongodb.com/docs/manual/reference/method/db.collection.findOneAndDelete/) command.
3573
3572
  *
3574
3573
  * Finds a matching document, removes it, and passes the found document (if any)
3575
3574
  * to the callback. Executes if `callback` is passed.
@@ -3579,7 +3578,7 @@ Query.prototype.findOneAndRemove = function(conditions, options, callback) {
3579
3578
  * - `findOneAndDelete()`
3580
3579
  *
3581
3580
  * This function differs slightly from `Model.findOneAndRemove()` in that
3582
- * `findOneAndRemove()` becomes a [MongoDB `findAndModify()` command](https://docs.mongodb.com/manual/reference/method/db.collection.findAndModify/),
3581
+ * `findOneAndRemove()` becomes a [MongoDB `findAndModify()` command](https://www.mongodb.com/docs/manual/reference/method/db.collection.findAndModify/),
3583
3582
  * as opposed to a `findOneAndDelete()` command. For most mongoose use cases,
3584
3583
  * this distinction is purely pedantic. You should use `findOneAndDelete()`
3585
3584
  * unless you have a good reason not to.
@@ -3697,7 +3696,7 @@ Query.prototype._findOneAndDelete = wrapThunk(function(callback) {
3697
3696
  });
3698
3697
 
3699
3698
  /**
3700
- * Issues a MongoDB [findOneAndReplace](https://docs.mongodb.com/manual/reference/method/db.collection.findOneAndReplace/) command.
3699
+ * Issues a MongoDB [findOneAndReplace](https://www.mongodb.com/docs/manual/reference/method/db.collection.findOneAndReplace/) command.
3701
3700
  *
3702
3701
  * Finds a matching document, removes it, and passes the found document (if any)
3703
3702
  * to the callback. Executes if `callback` is passed.
@@ -3737,7 +3736,7 @@ Query.prototype._findOneAndDelete = wrapThunk(function(callback) {
3737
3736
  * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html).
3738
3737
  * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
3739
3738
  * @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.
3740
- * @param {Object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](/docs/api/query.html#query_Query-lean) and [the Mongoose lean tutorial](/docs/tutorials/lean.html).
3739
+ * @param {Object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](#query_Query-lean) and [the Mongoose lean tutorial](/docs/tutorials/lean.html).
3741
3740
  * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html).
3742
3741
  * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
3743
3742
  * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](/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.
@@ -4396,7 +4395,7 @@ Query.prototype._replaceOne = wrapThunk(function(callback) {
4396
4395
  /**
4397
4396
  * Declare and/or execute this query as an update() operation.
4398
4397
  *
4399
- * _All paths passed that are not [atomic](https://docs.mongodb.com/manual/tutorial/model-data-for-atomic-operations/#pattern) operations will become `$set` ops._
4398
+ * _All paths passed that are not [atomic](https://www.mongodb.com/docs/manual/tutorial/model-data-for-atomic-operations/#pattern) operations will become `$set` ops._
4400
4399
  *
4401
4400
  * This function triggers the following middleware.
4402
4401
  *
@@ -4434,7 +4433,7 @@ Query.prototype._replaceOne = wrapThunk(function(callback) {
4434
4433
  *
4435
4434
  * q.update({ $set: { name: 'bob' }}).exec(); // executed
4436
4435
  *
4437
- * // keys that are not [atomic](https://docs.mongodb.com/manual/tutorial/model-data-for-atomic-operations/#pattern) ops become `$set`.
4436
+ * // keys that are not [atomic](https://www.mongodb.com/docs/manual/tutorial/model-data-for-atomic-operations/#pattern) ops become `$set`.
4438
4437
  * // this executes the same command as the previous example.
4439
4438
  * q.update({ name: 'bob' }).exec();
4440
4439
  *
@@ -4472,15 +4471,15 @@ Query.prototype._replaceOne = wrapThunk(function(callback) {
4472
4471
  * @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.
4473
4472
  * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
4474
4473
  * @param {Boolean} [options.upsert=false] if true, and no documents found, insert a new document
4475
- * @param {Object} [options.writeConcern=null] sets the [write concern](https://docs.mongodb.com/manual/reference/write-concern/) for replica sets. Overrides the [schema-level write concern](/docs/guide.html#writeConcern)
4474
+ * @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](/docs/guide.html#writeConcern)
4476
4475
  * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Does nothing if schema-level timestamps are not set.
4477
4476
  * @param {Function} [callback] params are (error, writeOpResult)
4478
4477
  * @return {Query} this
4479
4478
  * @see Model.update #model_Model-update
4480
4479
  * @see Query docs https://mongoosejs.com/docs/queries.html
4481
- * @see update https://docs.mongodb.org/manual/reference/method/db.collection.update/
4480
+ * @see update https://www.mongodb.com/docs/manual/reference/method/db.collection.update/
4482
4481
  * @see UpdateResult https://mongodb.github.io/node-mongodb-native/4.9/interfaces/UpdateResult.html
4483
- * @see MongoDB docs https://docs.mongodb.com/manual/reference/command/update/#update-command-output
4482
+ * @see MongoDB docs https://www.mongodb.com/docs/manual/reference/command/update/#update-command-output
4484
4483
  * @api public
4485
4484
  */
4486
4485
 
@@ -4537,15 +4536,15 @@ Query.prototype.update = function(conditions, doc, options, callback) {
4537
4536
  * @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.
4538
4537
  * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
4539
4538
  * @param {Boolean} [options.upsert=false] if true, and no documents found, insert a new document
4540
- * @param {Object} [options.writeConcern=null] sets the [write concern](https://docs.mongodb.com/manual/reference/write-concern/) for replica sets. Overrides the [schema-level write concern](/docs/guide.html#writeConcern)
4539
+ * @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](/docs/guide.html#writeConcern)
4541
4540
  * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Does nothing if schema-level timestamps are not set.
4542
4541
  * @param {Function} [callback] params are (error, writeOpResult)
4543
4542
  * @return {Query} this
4544
4543
  * @see Model.update #model_Model-update
4545
4544
  * @see Query docs https://mongoosejs.com/docs/queries.html
4546
- * @see update https://docs.mongodb.org/manual/reference/method/db.collection.update/
4545
+ * @see update https://www.mongodb.com/docs/manual/reference/method/db.collection.update/
4547
4546
  * @see UpdateResult https://mongodb.github.io/node-mongodb-native/4.9/interfaces/UpdateResult.html
4548
- * @see MongoDB docs https://docs.mongodb.com/manual/reference/command/update/#update-command-output
4547
+ * @see MongoDB docs https://www.mongodb.com/docs/manual/reference/command/update/#update-command-output
4549
4548
  * @api public
4550
4549
  */
4551
4550
 
@@ -4582,7 +4581,7 @@ Query.prototype.updateMany = function(conditions, doc, options, callback) {
4582
4581
  * `update()`, except it does not support the `multi` option.
4583
4582
  *
4584
4583
  * - MongoDB will update _only_ the first document that matches `filter` regardless of the value of the `multi` option.
4585
- * - Use `replaceOne()` if you want to overwrite an entire document rather than using [atomic](https://docs.mongodb.com/manual/tutorial/model-data-for-atomic-operations/#pattern) operators like `$set`.
4584
+ * - Use `replaceOne()` if you want to overwrite an entire document rather than using [atomic](https://www.mongodb.com/docs/manual/tutorial/model-data-for-atomic-operations/#pattern) operators like `$set`.
4586
4585
  *
4587
4586
  * **Note** updateOne will _not_ fire update middleware. Use `pre('updateOne')`
4588
4587
  * and `post('updateOne')` instead.
@@ -4606,15 +4605,15 @@ Query.prototype.updateMany = function(conditions, doc, options, callback) {
4606
4605
  * @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.
4607
4606
  * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
4608
4607
  * @param {Boolean} [options.upsert=false] if true, and no documents found, insert a new document
4609
- * @param {Object} [options.writeConcern=null] sets the [write concern](https://docs.mongodb.com/manual/reference/write-concern/) for replica sets. Overrides the [schema-level write concern](/docs/guide.html#writeConcern)
4608
+ * @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](/docs/guide.html#writeConcern)
4610
4609
  * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](/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.
4611
4610
  * @param {Function} [callback] params are (error, writeOpResult)
4612
4611
  * @return {Query} this
4613
4612
  * @see Model.update #model_Model-update
4614
4613
  * @see Query docs https://mongoosejs.com/docs/queries.html
4615
- * @see update https://docs.mongodb.org/manual/reference/method/db.collection.update/
4614
+ * @see update https://www.mongodb.com/docs/manual/reference/method/db.collection.update/
4616
4615
  * @see UpdateResult https://mongodb.github.io/node-mongodb-native/4.9/interfaces/UpdateResult.html
4617
- * @see MongoDB docs https://docs.mongodb.com/manual/reference/command/update/#update-command-output
4616
+ * @see MongoDB docs https://www.mongodb.com/docs/manual/reference/command/update/#update-command-output
4618
4617
  * @api public
4619
4618
  */
4620
4619
 
@@ -4649,7 +4648,7 @@ Query.prototype.updateOne = function(conditions, doc, options, callback) {
4649
4648
  /**
4650
4649
  * Declare and/or execute this query as a replaceOne() operation. Same as
4651
4650
  * `update()`, except MongoDB will replace the existing document and will
4652
- * not accept any [atomic](https://docs.mongodb.com/manual/tutorial/model-data-for-atomic-operations/#pattern) operators (`$set`, etc.)
4651
+ * not accept any [atomic](https://www.mongodb.com/docs/manual/tutorial/model-data-for-atomic-operations/#pattern) operators (`$set`, etc.)
4653
4652
  *
4654
4653
  * **Note** replaceOne will _not_ fire update middleware. Use `pre('replaceOne')`
4655
4654
  * and `post('replaceOne')` instead.
@@ -4673,15 +4672,15 @@ Query.prototype.updateOne = function(conditions, doc, options, callback) {
4673
4672
  * @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.
4674
4673
  * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
4675
4674
  * @param {Boolean} [options.upsert=false] if true, and no documents found, insert a new document
4676
- * @param {Object} [options.writeConcern=null] sets the [write concern](https://docs.mongodb.com/manual/reference/write-concern/) for replica sets. Overrides the [schema-level write concern](/docs/guide.html#writeConcern)
4675
+ * @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](/docs/guide.html#writeConcern)
4677
4676
  * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Does nothing if schema-level timestamps are not set.
4678
4677
  * @param {Function} [callback] params are (error, writeOpResult)
4679
4678
  * @return {Query} this
4680
4679
  * @see Model.update #model_Model-update
4681
4680
  * @see Query docs https://mongoosejs.com/docs/queries.html
4682
- * @see update https://docs.mongodb.org/manual/reference/method/db.collection.update/
4681
+ * @see update https://www.mongodb.com/docs/manual/reference/method/db.collection.update/
4683
4682
  * @see UpdateResult https://mongodb.github.io/node-mongodb-native/4.9/interfaces/UpdateResult.html
4684
- * @see MongoDB docs https://docs.mongodb.com/manual/reference/command/update/#update-command-output
4683
+ * @see MongoDB docs https://www.mongodb.com/docs/manual/reference/command/update/#update-command-output
4685
4684
  * @api public
4686
4685
  */
4687
4686
 
@@ -5100,7 +5099,9 @@ Query.prototype._castUpdate = function _castUpdate(obj, overwrite) {
5100
5099
  if (this._mongooseOptions.overwriteDiscriminatorKey &&
5101
5100
  obj[discriminatorKey] != null &&
5102
5101
  baseSchema.discriminators) {
5103
- const _schema = baseSchema.discriminators[obj[discriminatorKey]];
5102
+ const _schema = Object.values(baseSchema.discriminators).find(
5103
+ discriminator => discriminator.discriminatorMapping.value === obj[discriminatorKey]
5104
+ );
5104
5105
  if (_schema != null) {
5105
5106
  schema = _schema;
5106
5107
  }
@@ -5187,10 +5188,10 @@ function castQuery(query) {
5187
5188
  * @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.
5188
5189
  * @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`](/docs/schematypes.html#schematype-options).
5189
5190
  * @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.
5190
- * @param {Object|Function} [options.match=null] Add an additional filter to the populate query. Can be a filter object containing [MongoDB query syntax](https://docs.mongodb.com/manual/tutorial/query-documents/), or a function that returns a filter object.
5191
+ * @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.
5191
5192
  * @param {Function} [options.transform=null] Function that Mongoose will call on every populated document that allows you to transform the populated document.
5192
5193
  * @param {Object} [options.options=null] Additional options like `limit` and `lean`.
5193
- * @see population /docs/populate
5194
+ * @see population /docs/populate.html
5194
5195
  * @see Query#select #query_Query-select
5195
5196
  * @see Model.populate #model_Model-populate
5196
5197
  * @return {Query} this
@@ -5355,7 +5356,7 @@ Query.prototype.cast = function(model, obj) {
5355
5356
  *
5356
5357
  * @param {Object} fields
5357
5358
  * @see https://github.com/Automattic/mongoose/issues/1091
5358
- * @see https://docs.mongodb.org/manual/reference/projection/elemMatch/
5359
+ * @see https://www.mongodb.com/docs/manual/reference/projection/elemMatch/
5359
5360
  * @api private
5360
5361
  */
5361
5362
 
@@ -5461,7 +5462,7 @@ Query.prototype._applyPaths = function applyPaths() {
5461
5462
  *
5462
5463
  * @return {QueryCursor}
5463
5464
  * @param {Object} [options]
5464
- * @see QueryCursor /docs/api/querycursor
5465
+ * @see QueryCursor /docs/api/querycursor.html
5465
5466
  * @api public
5466
5467
  */
5467
5468
 
@@ -5519,7 +5520,7 @@ Query.prototype.maxscan = Query.base.maxScan;
5519
5520
  * @param {Object} [opts] options to set
5520
5521
  * @param {Boolean} [opts.awaitData] false by default. Set to true to keep the cursor open even if there's no data.
5521
5522
  * @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
5522
- * @see tailable https://docs.mongodb.org/manual/tutorial/create-tailable-cursor/
5523
+ * @see tailable https://www.mongodb.com/docs/manual/tutorial/create-tailable-cursor/
5523
5524
  * @api public
5524
5525
  */
5525
5526
 
@@ -5577,8 +5578,8 @@ Query.prototype.tailable = function(val, opts) {
5577
5578
  * @instance
5578
5579
  * @param {Object} [arg]
5579
5580
  * @return {Query} this
5580
- * @see $geometry https://docs.mongodb.org/manual/reference/operator/geometry/
5581
- * @see geoIntersects https://docs.mongodb.org/manual/reference/operator/geoIntersects/
5581
+ * @see $geometry https://www.mongodb.com/docs/manual/reference/operator/geometry/
5582
+ * @see geoIntersects https://www.mongodb.com/docs/manual/reference/operator/geoIntersects/
5582
5583
  * @api public
5583
5584
  */
5584
5585
 
@@ -5616,9 +5617,9 @@ Query.prototype.tailable = function(val, opts) {
5616
5617
  * @instance
5617
5618
  * @param {Object} object Must contain a `type` property which is a String and a `coordinates` property which is an Array. See the examples.
5618
5619
  * @return {Query} this
5619
- * @see $geometry https://docs.mongodb.org/manual/reference/operator/geometry/
5620
+ * @see $geometry https://www.mongodb.com/docs/manual/reference/operator/geometry/
5620
5621
  * @see Geospatial Support Enhancements https://www.mongodb.com/docs/manual/release-notes/2.4/#geospatial-support-enhancements
5621
- * @see MongoDB Geospatial Indexing https://www.mongodb.org/display/DOCS/Geospatial+Indexing
5622
+ * @see MongoDB Geospatial Indexing https://www.mongodb.com/docs/manual/core/geospatial-indexes/
5622
5623
  * @api public
5623
5624
  */
5624
5625
 
@@ -5640,10 +5641,10 @@ Query.prototype.tailable = function(val, opts) {
5640
5641
  * @param {String} [path]
5641
5642
  * @param {Object} val
5642
5643
  * @return {Query} this
5643
- * @see $near https://docs.mongodb.org/manual/reference/operator/near/
5644
- * @see $nearSphere https://docs.mongodb.org/manual/reference/operator/nearSphere/
5645
- * @see $maxDistance https://docs.mongodb.org/manual/reference/operator/maxDistance/
5646
- * @see MongoDB Geospatial Indexing https://www.mongodb.org/display/DOCS/Geospatial+Indexing
5644
+ * @see $near https://www.mongodb.com/docs/manual/reference/operator/near/
5645
+ * @see $nearSphere https://www.mongodb.com/docs/manual/reference/operator/nearSphere/
5646
+ * @see $maxDistance https://www.mongodb.com/docs/manual/reference/operator/maxDistance/
5647
+ * @see MongoDB Geospatial Indexing https://www.mongodb.com/docs/manual/core/geospatial-indexes/
5647
5648
  * @api public
5648
5649
  */
5649
5650
 
@@ -5727,9 +5728,9 @@ Query.prototype.near = function() {
5727
5728
  *
5728
5729
  * @deprecated
5729
5730
  * @see near() #query_Query-near
5730
- * @see $near https://docs.mongodb.org/manual/reference/operator/near/
5731
- * @see $nearSphere https://docs.mongodb.org/manual/reference/operator/nearSphere/
5732
- * @see $maxDistance https://docs.mongodb.org/manual/reference/operator/maxDistance/
5731
+ * @see $near https://www.mongodb.com/docs/manual/reference/operator/near/
5732
+ * @see $nearSphere https://www.mongodb.com/docs/manual/reference/operator/nearSphere/
5733
+ * @see $maxDistance https://www.mongodb.com/docs/manual/reference/operator/maxDistance/
5733
5734
  */
5734
5735
 
5735
5736
  Query.prototype.nearSphere = function() {
@@ -5783,8 +5784,8 @@ if (Symbol.asyncIterator != null) {
5783
5784
  * @param {String|Array} [path]
5784
5785
  * @param {Array|Object} [coordinatePairs...]
5785
5786
  * @return {Query} this
5786
- * @see $polygon https://docs.mongodb.org/manual/reference/operator/polygon/
5787
- * @see MongoDB Geospatial Indexing https://www.mongodb.org/display/DOCS/Geospatial+Indexing
5787
+ * @see $polygon https://www.mongodb.com/docs/manual/reference/operator/polygon/
5788
+ * @see MongoDB Geospatial Indexing https://www.mongodb.com/docs/manual/core/geospatial-indexes/
5788
5789
  * @api public
5789
5790
  */
5790
5791
 
@@ -5802,9 +5803,9 @@ if (Symbol.asyncIterator != null) {
5802
5803
  * @method box
5803
5804
  * @memberOf Query
5804
5805
  * @instance
5805
- * @see $box https://docs.mongodb.org/manual/reference/operator/box/
5806
+ * @see $box https://www.mongodb.com/docs/manual/reference/operator/box/
5806
5807
  * @see within() Query#within #query_Query-within
5807
- * @see MongoDB Geospatial Indexing https://www.mongodb.org/display/DOCS/Geospatial+Indexing
5808
+ * @see MongoDB Geospatial Indexing https://www.mongodb.com/docs/manual/core/geospatial-indexes/
5808
5809
  * @param {Object|Array<Number>} val1 Lower Left Coordinates OR a object of lower-left(ll) and upper-right(ur) Coordinates
5809
5810
  * @param {Array<Number>} [val2] Upper Right Coordinates
5810
5811
  * @return {Query} this
@@ -5852,10 +5853,10 @@ Query.prototype.box = function(ll, ur) {
5852
5853
  * @param {String} [path]
5853
5854
  * @param {Object} area
5854
5855
  * @return {Query} this
5855
- * @see $center https://docs.mongodb.org/manual/reference/operator/center/
5856
- * @see $centerSphere https://docs.mongodb.org/manual/reference/operator/centerSphere/
5857
- * @see $geoWithin https://docs.mongodb.org/manual/reference/operator/geoWithin/
5858
- * @see MongoDB Geospatial Indexing https://www.mongodb.org/display/DOCS/Geospatial+Indexing
5856
+ * @see $center https://www.mongodb.com/docs/manual/reference/operator/center/
5857
+ * @see $centerSphere https://www.mongodb.com/docs/manual/reference/operator/centerSphere/
5858
+ * @see $geoWithin https://www.mongodb.com/docs/manual/reference/operator/geoWithin/
5859
+ * @see MongoDB Geospatial Indexing https://www.mongodb.com/docs/manual/core/geospatial-indexes/
5859
5860
  * @api public
5860
5861
  */
5861
5862
 
@@ -5887,8 +5888,8 @@ Query.prototype.center = Query.base.circle;
5887
5888
  * @param {String} [path]
5888
5889
  * @param {Object} val
5889
5890
  * @return {Query} this
5890
- * @see MongoDB Geospatial Indexing https://www.mongodb.org/display/DOCS/Geospatial+Indexing
5891
- * @see $centerSphere https://docs.mongodb.org/manual/reference/operator/centerSphere/
5891
+ * @see MongoDB Geospatial Indexing https://www.mongodb.com/docs/manual/core/geospatial-indexes/
5892
+ * @see $centerSphere https://www.mongodb.com/docs/manual/reference/operator/centerSphere/
5892
5893
  * @api public
5893
5894
  */
5894
5895