mongoose 6.2.1 → 6.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.
Files changed (65) hide show
  1. package/.eslintrc.json +5 -1
  2. package/.lgtm.yml +3 -0
  3. package/CHANGELOG.md +54 -0
  4. package/dist/browser.umd.js +156 -152
  5. package/index.js +5 -1
  6. package/lib/aggregate.js +22 -27
  7. package/lib/browserDocument.js +1 -1
  8. package/lib/cast/number.js +2 -3
  9. package/lib/cast.js +7 -4
  10. package/lib/connection.js +43 -21
  11. package/lib/cursor/AggregationCursor.js +12 -7
  12. package/lib/cursor/QueryCursor.js +11 -6
  13. package/lib/document.js +58 -72
  14. package/lib/drivers/node-mongodb-native/collection.js +12 -4
  15. package/lib/drivers/node-mongodb-native/connection.js +11 -0
  16. package/lib/error/cast.js +3 -2
  17. package/lib/helpers/clone.js +11 -2
  18. package/lib/helpers/cursor/eachAsync.js +18 -15
  19. package/lib/helpers/document/cleanModifiedSubpaths.js +1 -0
  20. package/lib/helpers/document/compile.js +7 -4
  21. package/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js +14 -0
  22. package/lib/helpers/indexes/getRelatedIndexes.js +59 -0
  23. package/lib/helpers/isAsyncFunction.js +6 -7
  24. package/lib/helpers/populate/assignVals.js +4 -0
  25. package/lib/helpers/printJestWarning.js +2 -2
  26. package/lib/helpers/projection/applyProjection.js +77 -0
  27. package/lib/helpers/projection/hasIncludedChildren.js +36 -0
  28. package/lib/helpers/projection/isExclusive.js +5 -2
  29. package/lib/helpers/projection/isInclusive.js +5 -1
  30. package/lib/helpers/query/cast$expr.js +14 -19
  31. package/lib/helpers/query/hasDollarKeys.js +7 -3
  32. package/lib/helpers/query/isOperator.js +5 -2
  33. package/lib/helpers/schema/getIndexes.js +6 -2
  34. package/lib/index.js +14 -17
  35. package/lib/internal.js +9 -1
  36. package/lib/model.js +159 -153
  37. package/lib/options/SchemaTypeOptions.js +1 -1
  38. package/lib/plugins/trackTransaction.js +1 -1
  39. package/lib/query.js +159 -147
  40. package/lib/queryhelpers.js +8 -28
  41. package/lib/schema/SubdocumentPath.js +5 -4
  42. package/lib/schema/array.js +13 -6
  43. package/lib/schema/buffer.js +1 -1
  44. package/lib/schema/date.js +1 -1
  45. package/lib/schema/decimal128.js +1 -1
  46. package/lib/schema/documentarray.js +9 -7
  47. package/lib/schema/number.js +1 -1
  48. package/lib/schema/objectid.js +1 -1
  49. package/lib/schema/string.js +4 -4
  50. package/lib/schema.js +12 -8
  51. package/lib/schematype.js +12 -14
  52. package/lib/types/ArraySubdocument.js +1 -1
  53. package/lib/types/DocumentArray/index.js +1 -1
  54. package/lib/types/array/index.js +2 -2
  55. package/lib/types/array/methods/index.js +10 -11
  56. package/lib/types/buffer.js +3 -3
  57. package/lib/types/map.js +3 -4
  58. package/lib/utils.js +9 -3
  59. package/package.json +17 -21
  60. package/tsconfig.json +0 -2
  61. package/types/Connection.d.ts +212 -0
  62. package/types/Error.d.ts +129 -0
  63. package/types/PipelineStage.d.ts +272 -0
  64. package/types/index.d.ts +61 -602
  65. package/lib/types/array/ArrayWrapper.js +0 -981
package/lib/query.js CHANGED
@@ -18,7 +18,6 @@ const castArrayFilters = require('./helpers/update/castArrayFilters');
18
18
  const castNumber = require('./cast/number');
19
19
  const castUpdate = require('./helpers/query/castUpdate');
20
20
  const completeMany = require('./helpers/query/completeMany');
21
- const get = require('./helpers/get');
22
21
  const promiseOrCallback = require('./helpers/promiseOrCallback');
23
22
  const getDiscriminatorByValue = require('./helpers/discriminator/getDiscriminatorByValue');
24
23
  const hasDollarKeys = require('./helpers/query/hasDollarKeys');
@@ -110,7 +109,10 @@ function Query(conditions, options, model, collection) {
110
109
  // versions of MongoDB
111
110
  this.$useProjection = true;
112
111
 
113
- const collation = get(this, 'schema.options.collation', null);
112
+ const collation = this &&
113
+ this.schema &&
114
+ this.schema.options &&
115
+ this.schema.options.collation || null;
114
116
  if (collation != null) {
115
117
  this.options.collation = collation;
116
118
  }
@@ -131,7 +133,7 @@ Query.base = mquery.prototype;
131
133
  *
132
134
  * 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.
133
135
  *
134
- * @see http://docs.mongodb.org/manual/reference/operator/geoWithin/
136
+ * @see https://docs.mongodb.org/manual/reference/operator/geoWithin/
135
137
  * @default true
136
138
  * @property use$geoWithin
137
139
  * @memberOf Query
@@ -287,9 +289,9 @@ Query.prototype.clone = function clone() {
287
289
  * ####NOTE:
288
290
  *
289
291
  * Only use `$where` when you have a condition that cannot be met using other MongoDB operators like `$lt`.
290
- * **Be sure to read about all of [its caveats](http://docs.mongodb.org/manual/reference/operator/where/) before using.**
292
+ * **Be sure to read about all of [its caveats](https://docs.mongodb.org/manual/reference/operator/where/) before using.**
291
293
  *
292
- * @see $where http://docs.mongodb.org/manual/reference/operator/where/
294
+ * @see $where https://docs.mongodb.org/manual/reference/operator/where/
293
295
  * @method $where
294
296
  * @param {String|Function} js javascript string or function
295
297
  * @return {Query} this
@@ -346,8 +348,8 @@ Query.prototype.clone = function clone() {
346
348
  * @param {String} [path]
347
349
  * @param {Number} val number/range of elements to slice
348
350
  * @return {Query} this
349
- * @see mongodb http://www.mongodb.org/display/DOCS/Retrieving+a+Subset+of+Fields#RetrievingaSubsetofFields-RetrievingaSubrangeofArrayElements
350
- * @see $slice http://docs.mongodb.org/manual/reference/projection/slice/#prj._S_slice
351
+ * @see mongodb https://www.mongodb.org/display/DOCS/Retrieving+a+Subset+of+Fields#RetrievingaSubsetofFields-RetrievingaSubrangeofArrayElements
352
+ * @see $slice https://docs.mongodb.org/manual/reference/projection/slice/#prj._S_slice
351
353
  * @api public
352
354
  */
353
355
 
@@ -433,7 +435,7 @@ Query.prototype._validateOp = function() {
433
435
  *
434
436
  * query.or([{ color: 'red' }, { status: 'emergency' }])
435
437
  *
436
- * @see $or http://docs.mongodb.org/manual/reference/operator/or/
438
+ * @see $or https://docs.mongodb.org/manual/reference/operator/or/
437
439
  * @method or
438
440
  * @memberOf Query
439
441
  * @instance
@@ -449,7 +451,7 @@ Query.prototype._validateOp = function() {
449
451
  *
450
452
  * query.nor([{ color: 'green' }, { status: 'ok' }])
451
453
  *
452
- * @see $nor http://docs.mongodb.org/manual/reference/operator/nor/
454
+ * @see $nor https://docs.mongodb.org/manual/reference/operator/nor/
453
455
  * @method nor
454
456
  * @memberOf Query
455
457
  * @instance
@@ -468,7 +470,7 @@ Query.prototype._validateOp = function() {
468
470
  * @method and
469
471
  * @memberOf Query
470
472
  * @instance
471
- * @see $and http://docs.mongodb.org/manual/reference/operator/and/
473
+ * @see $and https://docs.mongodb.org/manual/reference/operator/and/
472
474
  * @param {Array} array array of conditions
473
475
  * @return {Query} this
474
476
  * @api public
@@ -491,7 +493,7 @@ Query.prototype._validateOp = function() {
491
493
  * @instance
492
494
  * @param {String} [path]
493
495
  * @param {Number} val
494
- * @see $gt http://docs.mongodb.org/manual/reference/operator/gt/
496
+ * @see $gt https://docs.mongodb.org/manual/reference/operator/gt/
495
497
  * @api public
496
498
  */
497
499
 
@@ -505,7 +507,7 @@ Query.prototype._validateOp = function() {
505
507
  * @instance
506
508
  * @param {String} [path]
507
509
  * @param {Number} val
508
- * @see $gte http://docs.mongodb.org/manual/reference/operator/gte/
510
+ * @see $gte https://docs.mongodb.org/manual/reference/operator/gte/
509
511
  * @api public
510
512
  */
511
513
 
@@ -519,7 +521,7 @@ Query.prototype._validateOp = function() {
519
521
  * @instance
520
522
  * @param {String} [path]
521
523
  * @param {Number} val
522
- * @see $lt http://docs.mongodb.org/manual/reference/operator/lt/
524
+ * @see $lt https://docs.mongodb.org/manual/reference/operator/lt/
523
525
  * @api public
524
526
  */
525
527
 
@@ -529,7 +531,7 @@ Query.prototype._validateOp = function() {
529
531
  * When called with one argument, the most recent path passed to `where()` is used.
530
532
  *
531
533
  * @method lte
532
- * @see $lte http://docs.mongodb.org/manual/reference/operator/lte/
534
+ * @see $lte https://docs.mongodb.org/manual/reference/operator/lte/
533
535
  * @memberOf Query
534
536
  * @instance
535
537
  * @param {String} [path]
@@ -542,7 +544,7 @@ Query.prototype._validateOp = function() {
542
544
  *
543
545
  * When called with one argument, the most recent path passed to `where()` is used.
544
546
  *
545
- * @see $ne http://docs.mongodb.org/manual/reference/operator/ne/
547
+ * @see $ne https://docs.mongodb.org/manual/reference/operator/ne/
546
548
  * @method ne
547
549
  * @memberOf Query
548
550
  * @instance
@@ -556,7 +558,7 @@ Query.prototype._validateOp = function() {
556
558
  *
557
559
  * When called with one argument, the most recent path passed to `where()` is used.
558
560
  *
559
- * @see $in http://docs.mongodb.org/manual/reference/operator/in/
561
+ * @see $in https://docs.mongodb.org/manual/reference/operator/in/
560
562
  * @method in
561
563
  * @memberOf Query
562
564
  * @instance
@@ -570,7 +572,7 @@ Query.prototype._validateOp = function() {
570
572
  *
571
573
  * When called with one argument, the most recent path passed to `where()` is used.
572
574
  *
573
- * @see $nin http://docs.mongodb.org/manual/reference/operator/nin/
575
+ * @see $nin https://docs.mongodb.org/manual/reference/operator/nin/
574
576
  * @method nin
575
577
  * @memberOf Query
576
578
  * @instance
@@ -590,7 +592,7 @@ Query.prototype._validateOp = function() {
590
592
  * // Equivalent:
591
593
  * MyModel.find().all('pets', ['dog', 'cat', 'ferret']);
592
594
  *
593
- * @see $all http://docs.mongodb.org/manual/reference/operator/all/
595
+ * @see $all https://docs.mongodb.org/manual/reference/operator/all/
594
596
  * @method all
595
597
  * @memberOf Query
596
598
  * @instance
@@ -610,7 +612,7 @@ Query.prototype._validateOp = function() {
610
612
  * assert(Array.isArray(docs));
611
613
  * console.log('documents with 0 tags', docs);
612
614
  *
613
- * @see $size http://docs.mongodb.org/manual/reference/operator/size/
615
+ * @see $size https://docs.mongodb.org/manual/reference/operator/size/
614
616
  * @method size
615
617
  * @memberOf Query
616
618
  * @instance
@@ -624,7 +626,7 @@ Query.prototype._validateOp = function() {
624
626
  *
625
627
  * When called with one argument, the most recent path passed to `where()` is used.
626
628
  *
627
- * @see $regex http://docs.mongodb.org/manual/reference/operator/regex/
629
+ * @see $regex https://docs.mongodb.org/manual/reference/operator/regex/
628
630
  * @method regex
629
631
  * @memberOf Query
630
632
  * @instance
@@ -638,7 +640,7 @@ Query.prototype._validateOp = function() {
638
640
  *
639
641
  * When called with one argument, the most recent path passed to `where()` is used.
640
642
  *
641
- * @see $maxDistance http://docs.mongodb.org/manual/reference/operator/maxDistance/
643
+ * @see $maxDistance https://docs.mongodb.org/manual/reference/operator/maxDistance/
642
644
  * @method maxDistance
643
645
  * @memberOf Query
644
646
  * @instance
@@ -665,7 +667,7 @@ Query.prototype._validateOp = function() {
665
667
  * @param {String} [path]
666
668
  * @param {Array} val must be of length 2, first element is `divisor`, 2nd element is `remainder`.
667
669
  * @return {Query} this
668
- * @see $mod http://docs.mongodb.org/manual/reference/operator/mod/
670
+ * @see $mod https://docs.mongodb.org/manual/reference/operator/mod/
669
671
  * @api public
670
672
  */
671
673
 
@@ -714,7 +716,7 @@ Query.prototype.mod = function() {
714
716
  * @param {String} [path]
715
717
  * @param {Boolean} val
716
718
  * @return {Query} this
717
- * @see $exists http://docs.mongodb.org/manual/reference/operator/exists/
719
+ * @see $exists https://docs.mongodb.org/manual/reference/operator/exists/
718
720
  * @api public
719
721
  */
720
722
 
@@ -743,7 +745,7 @@ Query.prototype.mod = function() {
743
745
  * @param {String|Object|Function} path
744
746
  * @param {Object|Function} filter
745
747
  * @return {Query} this
746
- * @see $elemMatch http://docs.mongodb.org/manual/reference/operator/elemMatch/
748
+ * @see $elemMatch https://docs.mongodb.org/manual/reference/operator/elemMatch/
747
749
  * @api public
748
750
  */
749
751
 
@@ -775,11 +777,11 @@ Query.prototype.mod = function() {
775
777
  * 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).
776
778
  *
777
779
  * @method within
778
- * @see $polygon http://docs.mongodb.org/manual/reference/operator/polygon/
779
- * @see $box http://docs.mongodb.org/manual/reference/operator/box/
780
- * @see $geometry http://docs.mongodb.org/manual/reference/operator/geometry/
781
- * @see $center http://docs.mongodb.org/manual/reference/operator/center/
782
- * @see $centerSphere http://docs.mongodb.org/manual/reference/operator/centerSphere/
780
+ * @see $polygon https://docs.mongodb.org/manual/reference/operator/polygon/
781
+ * @see $box https://docs.mongodb.org/manual/reference/operator/box/
782
+ * @see $geometry https://docs.mongodb.org/manual/reference/operator/geometry/
783
+ * @see $center https://docs.mongodb.org/manual/reference/operator/center/
784
+ * @see $centerSphere https://docs.mongodb.org/manual/reference/operator/centerSphere/
783
785
  * @memberOf Query
784
786
  * @instance
785
787
  * @return {Query} this
@@ -834,7 +836,7 @@ Query.prototype.limit = function limit(v) {
834
836
  * @memberOf Query
835
837
  * @instance
836
838
  * @param {Number} val
837
- * @see cursor.skip http://docs.mongodb.org/manual/reference/method/cursor.skip/
839
+ * @see cursor.skip https://docs.mongodb.org/manual/reference/method/cursor.skip/
838
840
  * @api public
839
841
  */
840
842
 
@@ -868,7 +870,7 @@ Query.prototype.skip = function skip(v) {
868
870
  * @memberOf Query
869
871
  * @instance
870
872
  * @param {Number} val
871
- * @see maxScan http://docs.mongodb.org/manual/reference/operator/maxScan/
873
+ * @see maxScan https://docs.mongodb.org/manual/reference/operator/maxScan/
872
874
  * @api public
873
875
  */
874
876
 
@@ -887,7 +889,7 @@ Query.prototype.skip = function skip(v) {
887
889
  * @memberOf Query
888
890
  * @instance
889
891
  * @param {Number} val
890
- * @see batchSize http://docs.mongodb.org/manual/reference/method/cursor.batchSize/
892
+ * @see batchSize https://docs.mongodb.org/manual/reference/method/cursor.batchSize/
891
893
  * @api public
892
894
  */
893
895
 
@@ -906,7 +908,7 @@ Query.prototype.skip = function skip(v) {
906
908
  * @memberOf Query
907
909
  * @instance
908
910
  * @param {String} val
909
- * @see comment http://docs.mongodb.org/manual/reference/operator/comment/
911
+ * @see comment https://docs.mongodb.org/manual/reference/operator/comment/
910
912
  * @api public
911
913
  */
912
914
 
@@ -926,7 +928,7 @@ Query.prototype.skip = function skip(v) {
926
928
  * @method snapshot
927
929
  * @memberOf Query
928
930
  * @instance
929
- * @see snapshot http://docs.mongodb.org/manual/reference/operator/snapshot/
931
+ * @see snapshot https://docs.mongodb.org/manual/reference/operator/snapshot/
930
932
  * @return {Query} this
931
933
  * @api public
932
934
  */
@@ -947,7 +949,7 @@ Query.prototype.skip = function skip(v) {
947
949
  * @instance
948
950
  * @param {Object} val a hint object
949
951
  * @return {Query} this
950
- * @see $hint http://docs.mongodb.org/manual/reference/operator/hint/
952
+ * @see $hint https://docs.mongodb.org/manual/reference/operator/hint/
951
953
  * @api public
952
954
  */
953
955
 
@@ -1128,8 +1130,8 @@ Query.prototype.select = function select() {
1128
1130
  * @instance
1129
1131
  * @deprecated use read() preferences instead if on mongodb >= 2.2
1130
1132
  * @param {Boolean} v defaults to true
1131
- * @see mongodb http://docs.mongodb.org/manual/applications/replication/#read-preference
1132
- * @see slaveOk http://docs.mongodb.org/manual/reference/method/rs.slaveOk/
1133
+ * @see mongodb https://docs.mongodb.org/manual/applications/replication/#read-preference
1134
+ * @see slaveOk https://docs.mongodb.org/manual/reference/method/rs.slaveOk/
1133
1135
  * @see read() #query_Query-read
1134
1136
  * @return {Query} this
1135
1137
  * @api public
@@ -1174,15 +1176,15 @@ Query.prototype.select = function select() {
1174
1176
  * // read from secondaries with matching tags
1175
1177
  * new Query().read('s', [{ dc:'sf', s: 1 },{ dc:'ma', s: 2 }])
1176
1178
  *
1177
- * Read more about how to use read preferences [here](http://docs.mongodb.org/manual/applications/replication/#read-preference) and [here](http://mongodb.github.com/node-mongodb-native/driver-articles/anintroductionto1_1and2_2.html#read-preferences).
1179
+ * Read more about how to use read preferences [here](https://docs.mongodb.org/manual/applications/replication/#read-preference) and [here](https://mongodb.github.com/node-mongodb-native/driver-articles/anintroductionto1_1and2_2.html#read-preferences).
1178
1180
  *
1179
1181
  * @method read
1180
1182
  * @memberOf Query
1181
1183
  * @instance
1182
1184
  * @param {String} pref one of the listed preference options or aliases
1183
1185
  * @param {Array} [tags] optional tags for this query
1184
- * @see mongodb http://docs.mongodb.org/manual/applications/replication/#read-preference
1185
- * @see driver http://mongodb.github.com/node-mongodb-native/driver-articles/anintroductionto1_1and2_2.html#read-preferences
1186
+ * @see mongodb https://docs.mongodb.org/manual/applications/replication/#read-preference
1187
+ * @see driver https://mongodb.github.com/node-mongodb-native/driver-articles/anintroductionto1_1and2_2.html#read-preferences
1186
1188
  * @return {Query} this
1187
1189
  * @api public
1188
1190
  */
@@ -1513,16 +1515,16 @@ Query.prototype.getOptions = function() {
1513
1515
  *
1514
1516
  * The following options are only for `find()`:
1515
1517
  *
1516
- * - [tailable](http://www.mongodb.org/display/DOCS/Tailable+Cursors)
1517
- * - [sort](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Bsort(\)%7D%7D)
1518
- * - [limit](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Blimit%28%29%7D%7D)
1519
- * - [skip](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Bskip%28%29%7D%7D)
1518
+ * - [tailable](https://www.mongodb.org/display/DOCS/Tailable+Cursors)
1519
+ * - [sort](https://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Bsort(\)%7D%7D)
1520
+ * - [limit](https://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Blimit%28%29%7D%7D)
1521
+ * - [skip](https://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Bskip%28%29%7D%7D)
1520
1522
  * - [allowDiskUse](https://docs.mongodb.com/manual/reference/method/cursor.allowDiskUse/)
1521
- * - [batchSize](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7BbatchSize%28%29%7D%7D)
1522
- * - [readPreference](http://docs.mongodb.org/manual/applications/replication/#read-preference)
1523
- * - [hint](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24hint)
1524
- * - [comment](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24comment)
1525
- * - [snapshot](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Bsnapshot%28%29%7D%7D)
1523
+ * - [batchSize](https://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7BbatchSize%28%29%7D%7D)
1524
+ * - [readPreference](https://docs.mongodb.org/manual/applications/replication/#read-preference)
1525
+ * - [hint](https://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24hint)
1526
+ * - [comment](https://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24comment)
1527
+ * - [snapshot](https://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Bsnapshot%28%29%7D%7D)
1526
1528
  * - [maxscan](https://docs.mongodb.org/v3.2/reference/operator/meta/maxScan/#metaOp._S_maxScan)
1527
1529
  *
1528
1530
  * The following options are only for write operations: `update()`, `updateOne()`, `updateMany()`, `replaceOne()`, `findOneAndUpdate()`, and `findByIdAndUpdate()`:
@@ -1911,7 +1913,10 @@ Query.prototype._optionsForExec = function(model) {
1911
1913
  // Apply schema-level `writeConcern` option
1912
1914
  applyWriteConcern(model.schema, options);
1913
1915
 
1914
- const readPreference = get(model, 'schema.options.read');
1916
+ const readPreference = model &&
1917
+ model.schema &&
1918
+ model.schema.options &&
1919
+ model.schema.options.read;
1915
1920
  if (!('readPreference' in options) && readPreference) {
1916
1921
  options.readPreference = readPreference;
1917
1922
  }
@@ -2184,7 +2189,7 @@ Query.prototype._find = wrapThunk(function(callback) {
2184
2189
  // Separate options to pass down to `completeMany()` in case we need to
2185
2190
  // set a session on the document
2186
2191
  const completeManyOptions = Object.assign({}, {
2187
- session: get(this, 'options.session', null)
2192
+ session: this && this.options && this.options.session || null
2188
2193
  });
2189
2194
 
2190
2195
  const cb = (err, docs) => {
@@ -2409,7 +2414,7 @@ Query.prototype._completeOne = function(doc, res, callback) {
2409
2414
  * Thunk around findOne()
2410
2415
  *
2411
2416
  * @param {Function} [callback]
2412
- * @see findOne http://docs.mongodb.org/manual/reference/method/db.collection.findOne/
2417
+ * @see findOne https://docs.mongodb.org/manual/reference/method/db.collection.findOne/
2413
2418
  * @api private
2414
2419
  */
2415
2420
 
@@ -2463,10 +2468,10 @@ Query.prototype._findOne = wrapThunk(function(callback) {
2463
2468
  *
2464
2469
  * @param {Object} [filter] mongodb selector
2465
2470
  * @param {Object} [projection] optional fields to return
2466
- * @param {Object} [options] see [`setOptions()`](http://mongoosejs.com/docs/api.html#query_Query-setOptions)
2471
+ * @param {Object} [options] see [`setOptions()`](https://mongoosejs.com/docs/api.html#query_Query-setOptions)
2467
2472
  * @param {Function} [callback] optional params are (error, document)
2468
2473
  * @return {Query} this
2469
- * @see findOne http://docs.mongodb.org/manual/reference/method/db.collection.findOne/
2474
+ * @see findOne https://docs.mongodb.org/manual/reference/method/db.collection.findOne/
2470
2475
  * @see Query.select #query_Query-select
2471
2476
  * @api public
2472
2477
  */
@@ -2521,7 +2526,7 @@ Query.prototype.findOne = function(conditions, projection, options, callback) {
2521
2526
  * Thunk around count()
2522
2527
  *
2523
2528
  * @param {Function} [callback]
2524
- * @see count http://docs.mongodb.org/manual/reference/method/db.collection.count/
2529
+ * @see count https://docs.mongodb.org/manual/reference/method/db.collection.count/
2525
2530
  * @api private
2526
2531
  */
2527
2532
 
@@ -2548,7 +2553,7 @@ Query.prototype._count = wrapThunk(function(callback) {
2548
2553
  * Thunk around countDocuments()
2549
2554
  *
2550
2555
  * @param {Function} [callback]
2551
- * @see countDocuments http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#countDocuments
2556
+ * @see countDocuments https://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#countDocuments
2552
2557
  * @api private
2553
2558
  */
2554
2559
 
@@ -2575,7 +2580,7 @@ Query.prototype._countDocuments = wrapThunk(function(callback) {
2575
2580
  * Thunk around estimatedDocumentCount()
2576
2581
  *
2577
2582
  * @param {Function} [callback]
2578
- * @see estimatedDocumentCount http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#estimatedDocumentCount
2583
+ * @see estimatedDocumentCount https://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#estimatedDocumentCount
2579
2584
  * @api private
2580
2585
  */
2581
2586
 
@@ -2619,7 +2624,7 @@ Query.prototype._estimatedDocumentCount = wrapThunk(function(callback) {
2619
2624
  * @param {Object} [filter] count documents that match this object
2620
2625
  * @param {Function} [callback] optional params are (error, count)
2621
2626
  * @return {Query} this
2622
- * @see count http://docs.mongodb.org/manual/reference/method/db.collection.count/
2627
+ * @see count https://docs.mongodb.org/manual/reference/method/db.collection.count/
2623
2628
  * @api public
2624
2629
  */
2625
2630
 
@@ -2663,10 +2668,10 @@ Query.prototype.count = function(filter, callback) {
2663
2668
  *
2664
2669
  * await Model.find().estimatedDocumentCount();
2665
2670
  *
2666
- * @param {Object} [options] passed transparently to the [MongoDB driver](http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#estimatedDocumentCount)
2671
+ * @param {Object} [options] passed transparently to the [MongoDB driver](https://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#estimatedDocumentCount)
2667
2672
  * @param {Function} [callback] optional params are (error, count)
2668
2673
  * @return {Query} this
2669
- * @see estimatedDocumentCount http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#estimatedDocumentCount
2674
+ * @see estimatedDocumentCount https://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#estimatedDocumentCount
2670
2675
  * @api public
2671
2676
  */
2672
2677
 
@@ -2696,7 +2701,7 @@ Query.prototype.estimatedDocumentCount = function(options, callback) {
2696
2701
  * except it always does a full collection scan when passed an empty filter `{}`.
2697
2702
  *
2698
2703
  * There are also minor differences in how `countDocuments()` handles
2699
- * [`$where` and a couple geospatial operators](http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#countDocuments).
2704
+ * [`$where` and a couple geospatial operators](https://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#countDocuments).
2700
2705
  * versus `count()`.
2701
2706
  *
2702
2707
  * Passing a `callback` executes the query.
@@ -2731,7 +2736,7 @@ Query.prototype.estimatedDocumentCount = function(options, callback) {
2731
2736
  * @param {Object} [options]
2732
2737
  * @param {Function} [callback] optional params are (error, count)
2733
2738
  * @return {Query} this
2734
- * @see countDocuments http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#countDocuments
2739
+ * @see countDocuments https://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#countDocuments
2735
2740
  * @api public
2736
2741
  */
2737
2742
 
@@ -2771,7 +2776,7 @@ Query.prototype.countDocuments = function(conditions, options, callback) {
2771
2776
  * Thunk around distinct()
2772
2777
  *
2773
2778
  * @param {Function} [callback]
2774
- * @see distinct http://docs.mongodb.org/manual/reference/method/db.collection.distinct/
2779
+ * @see distinct https://docs.mongodb.org/manual/reference/method/db.collection.distinct/
2775
2780
  * @api private
2776
2781
  */
2777
2782
 
@@ -2812,7 +2817,7 @@ Query.prototype.__distinct = wrapThunk(function __distinct(callback) {
2812
2817
  * @param {Object|Query} [filter]
2813
2818
  * @param {Function} [callback] optional params are (error, arr)
2814
2819
  * @return {Query} this
2815
- * @see distinct http://docs.mongodb.org/manual/reference/method/db.collection.distinct/
2820
+ * @see distinct https://docs.mongodb.org/manual/reference/method/db.collection.distinct/
2816
2821
  * @api public
2817
2822
  */
2818
2823
 
@@ -2874,7 +2879,7 @@ Query.prototype.distinct = function(field, conditions, callback) {
2874
2879
  *
2875
2880
  * @param {Object|String} arg
2876
2881
  * @return {Query} this
2877
- * @see cursor.sort http://docs.mongodb.org/manual/reference/method/cursor.sort/
2882
+ * @see cursor.sort https://docs.mongodb.org/manual/reference/method/cursor.sort/
2878
2883
  * @api public
2879
2884
  */
2880
2885
 
@@ -2897,7 +2902,7 @@ Query.prototype.sort = function(arg) {
2897
2902
  *
2898
2903
  * Character.remove({ name: /Stark/ }, callback);
2899
2904
  *
2900
- * This function calls the MongoDB driver's [`Collection#remove()` function](http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#remove).
2905
+ * This function calls the MongoDB driver's [`Collection#remove()` function](https://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#remove).
2901
2906
  * The returned [promise](https://mongoosejs.com/docs/queries.html) resolves to an
2902
2907
  * object that contains 3 properties:
2903
2908
  *
@@ -2931,8 +2936,8 @@ Query.prototype.sort = function(arg) {
2931
2936
  * @param {Function} [callback] optional params are (error, mongooseDeleteResult)
2932
2937
  * @return {Query} this
2933
2938
  * @deprecated
2934
- * @see deleteWriteOpResult http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#~deleteWriteOpResult
2935
- * @see MongoDB driver remove http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#remove
2939
+ * @see deleteWriteOpResult https://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#~deleteWriteOpResult
2940
+ * @see MongoDB driver remove https://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#remove
2936
2941
  * @api public
2937
2942
  */
2938
2943
 
@@ -2975,7 +2980,7 @@ Query.prototype._remove = wrapThunk(function(callback) {
2975
2980
 
2976
2981
  callback = _wrapThunkCallback(this, callback);
2977
2982
 
2978
- return Query.base.remove.call(this, helpers.handleDeleteWriteOpResult(callback));
2983
+ return Query.base.remove.call(this, callback);
2979
2984
  });
2980
2985
 
2981
2986
  /**
@@ -2992,7 +2997,7 @@ Query.prototype._remove = wrapThunk(function(callback) {
2992
2997
  * // Using callbacks:
2993
2998
  * Character.deleteOne({ name: 'Eddard Stark' }, callback);
2994
2999
  *
2995
- * This function calls the MongoDB driver's [`Collection#deleteOne()` function](http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#deleteOne).
3000
+ * This function calls the MongoDB driver's [`Collection#deleteOne()` function](https://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#deleteOne).
2996
3001
  * The returned [promise](https://mongoosejs.com/docs/queries.html) resolves to an
2997
3002
  * object that contains 3 properties:
2998
3003
  *
@@ -3007,11 +3012,11 @@ Query.prototype._remove = wrapThunk(function(callback) {
3007
3012
  * res.deletedCount;
3008
3013
  *
3009
3014
  * @param {Object|Query} [filter] mongodb selector
3010
- * @param {Object} [options] optional see [`Query.prototype.setOptions()`](http://mongoosejs.com/docs/api.html#query_Query-setOptions)
3015
+ * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api.html#query_Query-setOptions)
3011
3016
  * @param {Function} [callback] optional params are (error, mongooseDeleteResult)
3012
3017
  * @return {Query} this
3013
- * @see deleteWriteOpResult http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#~deleteWriteOpResult
3014
- * @see MongoDB Driver deleteOne http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#deleteOne
3018
+ * @see deleteWriteOpResult https://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#~deleteWriteOpResult
3019
+ * @see MongoDB Driver deleteOne https://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#deleteOne
3015
3020
  * @api public
3016
3021
  */
3017
3022
 
@@ -3061,7 +3066,7 @@ Query.prototype._deleteOne = wrapThunk(function(callback) {
3061
3066
 
3062
3067
  callback = _wrapThunkCallback(this, callback);
3063
3068
 
3064
- return Query.base.deleteOne.call(this, helpers.handleDeleteWriteOpResult(callback));
3069
+ return Query.base.deleteOne.call(this, callback);
3065
3070
  });
3066
3071
 
3067
3072
  /**
@@ -3078,7 +3083,7 @@ Query.prototype._deleteOne = wrapThunk(function(callback) {
3078
3083
  * // Using callbacks:
3079
3084
  * Character.deleteMany({ name: /Stark/, age: { $gte: 18 } }, callback);
3080
3085
  *
3081
- * This function calls the MongoDB driver's [`Collection#deleteMany()` function](http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#deleteMany).
3086
+ * This function calls the MongoDB driver's [`Collection#deleteMany()` function](https://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#deleteMany).
3082
3087
  * The returned [promise](https://mongoosejs.com/docs/queries.html) resolves to an
3083
3088
  * object that contains 3 properties:
3084
3089
  *
@@ -3093,11 +3098,11 @@ Query.prototype._deleteOne = wrapThunk(function(callback) {
3093
3098
  * res.deletedCount;
3094
3099
  *
3095
3100
  * @param {Object|Query} [filter] mongodb selector
3096
- * @param {Object} [options] optional see [`Query.prototype.setOptions()`](http://mongoosejs.com/docs/api.html#query_Query-setOptions)
3101
+ * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api.html#query_Query-setOptions)
3097
3102
  * @param {Function} [callback] optional params are (error, mongooseDeleteResult)
3098
3103
  * @return {Query} this
3099
- * @see deleteWriteOpResult http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#~deleteWriteOpResult
3100
- * @see MongoDB Driver deleteMany http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#deleteMany
3104
+ * @see deleteWriteOpResult https://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#~deleteWriteOpResult
3105
+ * @see MongoDB Driver deleteMany https://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#deleteMany
3101
3106
  * @api public
3102
3107
  */
3103
3108
 
@@ -3147,7 +3152,7 @@ Query.prototype._deleteMany = wrapThunk(function(callback) {
3147
3152
 
3148
3153
  callback = _wrapThunkCallback(this, callback);
3149
3154
 
3150
- return Query.base.deleteMany.call(this, helpers.handleDeleteWriteOpResult(callback));
3155
+ return Query.base.deleteMany.call(this, callback);
3151
3156
  });
3152
3157
 
3153
3158
  /*!
@@ -3220,7 +3225,7 @@ function prepareDiscriminatorCriteria(query) {
3220
3225
  }
3221
3226
 
3222
3227
  /**
3223
- * Issues a mongodb [findAndModify](http://www.mongodb.org/display/DOCS/findAndModify+Command) update command.
3228
+ * Issues a mongodb [findAndModify](https://www.mongodb.org/display/DOCS/findAndModify+Command) update command.
3224
3229
  *
3225
3230
  * Finds a matching document, updates it according to the `update` arg, passing any `options`, and returns the found
3226
3231
  * document (if any) to the callback. The query executes if
@@ -3238,8 +3243,8 @@ function prepareDiscriminatorCriteria(query) {
3238
3243
  * - `sort`: if multiple docs are found by the conditions, sets the sort order to choose which doc to update
3239
3244
  * - `maxTimeMS`: puts a time limit on the query - requires mongodb >= 2.6.0
3240
3245
  * - `runValidators`: if true, runs [update validators](/docs/validation.html#update-validators) on this command. Update validators validate the update operation against the model's schema.
3241
- * - `setDefaultsOnInsert`: `true` by default. If `setDefaultsOnInsert` and `upsert` are true, mongoose will apply the [defaults](http://mongoosejs.com/docs/defaults.html) specified in the model's schema if a new document is created.
3242
- * - `rawResult`: if true, returns the [raw result from the MongoDB driver](http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify)
3246
+ * - `setDefaultsOnInsert`: `true` by default. If `setDefaultsOnInsert` and `upsert` are true, mongoose will apply the [defaults](https://mongoosejs.com/docs/defaults.html) specified in the model's schema if a new document is created.
3247
+ * - `rawResult`: if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify)
3243
3248
  *
3244
3249
  * ####Callback Signature
3245
3250
  * function(error, doc) {
@@ -3264,20 +3269,20 @@ function prepareDiscriminatorCriteria(query) {
3264
3269
  * @param {Object|Query} [filter]
3265
3270
  * @param {Object} [doc]
3266
3271
  * @param {Object} [options]
3267
- * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify)
3268
- * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](http://mongoosejs.com/docs/guide.html#strict)
3272
+ * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify)
3273
+ * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
3269
3274
  * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html).
3270
3275
  * @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.
3271
3276
  * @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.
3272
3277
  * @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.html#query_Query-lean) and [the Mongoose lean tutorial](/docs/tutorials/lean.html).
3273
3278
  * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html).
3274
- * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](http://mongoosejs.com/docs/guide.html#strict)
3279
+ * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
3275
3280
  * @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.
3276
3281
  * @param {Boolean} [options.returnOriginal=null] An alias for the `new` option. `returnOriginal: false` is equivalent to `new: true`.
3277
3282
  * @param {Function} [callback] optional params are (error, doc), _unless_ `rawResult` is used, in which case params are (error, writeOpResult)
3278
3283
  * @see Tutorial /docs/tutorials/findoneandupdate.html
3279
- * @see mongodb http://www.mongodb.org/display/DOCS/findAndModify+Command
3280
- * @see writeOpResult http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#~WriteOpResult
3284
+ * @see mongodb https://www.mongodb.org/display/DOCS/findAndModify+Command
3285
+ * @see writeOpResult https://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#~WriteOpResult
3281
3286
  * @return {Query} this
3282
3287
  * @api public
3283
3288
  */
@@ -3332,8 +3337,11 @@ Query.prototype.findOneAndUpdate = function(criteria, doc, options, callback) {
3332
3337
  delete options.fields;
3333
3338
  }
3334
3339
 
3335
-
3336
- const returnOriginal = get(this, 'model.base.options.returnOriginal');
3340
+ const returnOriginal = this &&
3341
+ this.model &&
3342
+ this.model.base &&
3343
+ this.model.base.options &&
3344
+ this.model.base.options.returnOriginal;
3337
3345
  if (options.new == null && options.returnDocument == null && options.returnOriginal == null && returnOriginal != null) {
3338
3346
  options.returnOriginal = returnOriginal;
3339
3347
  }
@@ -3365,7 +3373,7 @@ Query.prototype._findOneAndUpdate = wrapThunk(function(callback) {
3365
3373
  });
3366
3374
 
3367
3375
  /**
3368
- * Issues a mongodb [findAndModify](http://www.mongodb.org/display/DOCS/findAndModify+Command) remove command.
3376
+ * Issues a mongodb [findAndModify](https://www.mongodb.org/display/DOCS/findAndModify+Command) remove command.
3369
3377
  *
3370
3378
  * Finds a matching document, removes it, passing the found document (if any) to
3371
3379
  * the callback. Executes if `callback` is passed.
@@ -3378,7 +3386,7 @@ Query.prototype._findOneAndUpdate = wrapThunk(function(callback) {
3378
3386
  *
3379
3387
  * - `sort`: if multiple docs are found by the conditions, sets the sort order to choose which doc to update
3380
3388
  * - `maxTimeMS`: puts a time limit on the query - requires mongodb >= 2.6.0
3381
- * - `rawResult`: if true, resolves to the [raw result from the MongoDB driver](http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify)
3389
+ * - `rawResult`: if true, resolves to the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify)
3382
3390
  *
3383
3391
  * ####Callback Signature
3384
3392
  * function(error, doc) {
@@ -3400,12 +3408,12 @@ Query.prototype._findOneAndUpdate = wrapThunk(function(callback) {
3400
3408
  * @instance
3401
3409
  * @param {Object} [conditions]
3402
3410
  * @param {Object} [options]
3403
- * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify)
3411
+ * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify)
3404
3412
  * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html).
3405
- * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](http://mongoosejs.com/docs/guide.html#strict)
3413
+ * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
3406
3414
  * @param {Function} [callback] optional params are (error, document)
3407
3415
  * @return {Query} this
3408
- * @see mongodb http://www.mongodb.org/display/DOCS/findAndModify+Command
3416
+ * @see mongodb https://www.mongodb.org/display/DOCS/findAndModify+Command
3409
3417
  * @api public
3410
3418
  */
3411
3419
 
@@ -3465,7 +3473,7 @@ Query.prototype.findOneAndRemove = function(conditions, options, callback) {
3465
3473
  *
3466
3474
  * - `sort`: if multiple docs are found by the conditions, sets the sort order to choose which doc to update
3467
3475
  * - `maxTimeMS`: puts a time limit on the query - requires mongodb >= 2.6.0
3468
- * - `rawResult`: if true, resolves to the [raw result from the MongoDB driver](http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify)
3476
+ * - `rawResult`: if true, resolves to the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify)
3469
3477
  *
3470
3478
  * ####Callback Signature
3471
3479
  * function(error, doc) {
@@ -3486,12 +3494,12 @@ Query.prototype.findOneAndRemove = function(conditions, options, callback) {
3486
3494
  * @memberOf Query
3487
3495
  * @param {Object} [conditions]
3488
3496
  * @param {Object} [options]
3489
- * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify)
3497
+ * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify)
3490
3498
  * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html).
3491
- * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](http://mongoosejs.com/docs/guide.html#strict)
3499
+ * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
3492
3500
  * @param {Function} [callback] optional params are (error, document)
3493
3501
  * @return {Query} this
3494
- * @see mongodb http://www.mongodb.org/display/DOCS/findAndModify+Command
3502
+ * @see mongodb https://www.mongodb.org/display/DOCS/findAndModify+Command
3495
3503
  * @api public
3496
3504
  */
3497
3505
 
@@ -3584,7 +3592,7 @@ Query.prototype._findOneAndDelete = wrapThunk(function(callback) {
3584
3592
  *
3585
3593
  * - `sort`: if multiple docs are found by the conditions, sets the sort order to choose which doc to update
3586
3594
  * - `maxTimeMS`: puts a time limit on the query - requires mongodb >= 2.6.0
3587
- * - `rawResult`: if true, resolves to the [raw result from the MongoDB driver](http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify)
3595
+ * - `rawResult`: if true, resolves to the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify)
3588
3596
  *
3589
3597
  * ####Callback Signature
3590
3598
  * function(error, doc) {
@@ -3606,13 +3614,13 @@ Query.prototype._findOneAndDelete = wrapThunk(function(callback) {
3606
3614
  * @param {Object} [filter]
3607
3615
  * @param {Object} [replacement]
3608
3616
  * @param {Object} [options]
3609
- * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify)
3617
+ * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify)
3610
3618
  * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html).
3611
- * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](http://mongoosejs.com/docs/guide.html#strict)
3619
+ * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
3612
3620
  * @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.
3613
3621
  * @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.html#query_Query-lean) and [the Mongoose lean tutorial](/docs/tutorials/lean.html).
3614
3622
  * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html).
3615
- * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](http://mongoosejs.com/docs/guide.html#strict)
3623
+ * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
3616
3624
  * @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.
3617
3625
  * @param {Boolean} [options.returnOriginal=null] An alias for the `new` option. `returnOriginal: false` is equivalent to `new: true`.
3618
3626
  * @param {Function} [callback] optional params are (error, document)
@@ -3661,7 +3669,11 @@ Query.prototype.findOneAndReplace = function(filter, replacement, options, callb
3661
3669
 
3662
3670
  options = options || {};
3663
3671
 
3664
- const returnOriginal = get(this, 'model.base.options.returnOriginal');
3672
+ const returnOriginal = this &&
3673
+ this.model &&
3674
+ this.model.base &&
3675
+ this.model.base.options &&
3676
+ this.model.base.options.returnOriginal;
3665
3677
  if (options.new == null && options.returnDocument == null && options.returnOriginal == null && returnOriginal != null) {
3666
3678
  options.returnOriginal = returnOriginal;
3667
3679
  }
@@ -4166,7 +4178,7 @@ Query.prototype._replaceOne = wrapThunk(function(callback) {
4166
4178
  * - `upsert` (boolean) whether to create the doc if it doesn't match (false)
4167
4179
  * - `multi` (boolean) whether multiple documents should be updated (false)
4168
4180
  * - `runValidators` (boolean) if true, runs [update validators](/docs/validation.html#update-validators) on this command. Update validators validate the update operation against the model's schema.
4169
- * - `setDefaultsOnInsert` (boolean) `true` by default. If `setDefaultsOnInsert` and `upsert` are true, mongoose will apply the [defaults](http://mongoosejs.com/docs/defaults.html) specified in the model's schema if a new document is created.
4181
+ * - `setDefaultsOnInsert` (boolean) `true` by default. If `setDefaultsOnInsert` and `upsert` are true, mongoose will apply the [defaults](https://mongoosejs.com/docs/defaults.html) specified in the model's schema if a new document is created.
4170
4182
  * - `strict` (boolean) overrides the `strict` option for this update
4171
4183
  * - `read`
4172
4184
  * - `writeConcern`
@@ -4217,7 +4229,7 @@ Query.prototype._replaceOne = wrapThunk(function(callback) {
4217
4229
  * @param {Object} [doc] the update command
4218
4230
  * @param {Object} [options]
4219
4231
  * @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.
4220
- * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](http://mongoosejs.com/docs/guide.html#strict)
4232
+ * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
4221
4233
  * @param {Boolean} [options.upsert=false] if true, and no documents found, insert a new document
4222
4234
  * @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)
4223
4235
  * @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.
@@ -4225,8 +4237,8 @@ Query.prototype._replaceOne = wrapThunk(function(callback) {
4225
4237
  * @return {Query} this
4226
4238
  * @see Model.update #model_Model.update
4227
4239
  * @see Query docs https://mongoosejs.com/docs/queries.html
4228
- * @see update http://docs.mongodb.org/manual/reference/method/db.collection.update/
4229
- * @see writeOpResult http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#~WriteOpResult
4240
+ * @see update https://docs.mongodb.org/manual/reference/method/db.collection.update/
4241
+ * @see writeOpResult https://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#~WriteOpResult
4230
4242
  * @see MongoDB docs https://docs.mongodb.com/manual/reference/command/update/#update-command-output
4231
4243
  * @api public
4232
4244
  */
@@ -4281,7 +4293,7 @@ Query.prototype.update = function(conditions, doc, options, callback) {
4281
4293
  * @param {Object|Array} [update] the update command
4282
4294
  * @param {Object} [options]
4283
4295
  * @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.
4284
- * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](http://mongoosejs.com/docs/guide.html#strict)
4296
+ * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
4285
4297
  * @param {Boolean} [options.upsert=false] if true, and no documents found, insert a new document
4286
4298
  * @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)
4287
4299
  * @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.
@@ -4289,8 +4301,8 @@ Query.prototype.update = function(conditions, doc, options, callback) {
4289
4301
  * @return {Query} this
4290
4302
  * @see Model.update #model_Model.update
4291
4303
  * @see Query docs https://mongoosejs.com/docs/queries.html
4292
- * @see update http://docs.mongodb.org/manual/reference/method/db.collection.update/
4293
- * @see writeOpResult http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#~WriteOpResult
4304
+ * @see update https://docs.mongodb.org/manual/reference/method/db.collection.update/
4305
+ * @see writeOpResult https://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#~WriteOpResult
4294
4306
  * @see MongoDB docs https://docs.mongodb.com/manual/reference/command/update/#update-command-output
4295
4307
  * @api public
4296
4308
  */
@@ -4346,7 +4358,7 @@ Query.prototype.updateMany = function(conditions, doc, options, callback) {
4346
4358
  * @param {Object|Array} [update] the update command
4347
4359
  * @param {Object} [options]
4348
4360
  * @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.
4349
- * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](http://mongoosejs.com/docs/guide.html#strict)
4361
+ * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
4350
4362
  * @param {Boolean} [options.upsert=false] if true, and no documents found, insert a new document
4351
4363
  * @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)
4352
4364
  * @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.
@@ -4354,8 +4366,8 @@ Query.prototype.updateMany = function(conditions, doc, options, callback) {
4354
4366
  * @return {Query} this
4355
4367
  * @see Model.update #model_Model.update
4356
4368
  * @see Query docs https://mongoosejs.com/docs/queries.html
4357
- * @see update http://docs.mongodb.org/manual/reference/method/db.collection.update/
4358
- * @see writeOpResult http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#~WriteOpResult
4369
+ * @see update https://docs.mongodb.org/manual/reference/method/db.collection.update/
4370
+ * @see writeOpResult https://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#~WriteOpResult
4359
4371
  * @see MongoDB docs https://docs.mongodb.com/manual/reference/command/update/#update-command-output
4360
4372
  * @api public
4361
4373
  */
@@ -4409,7 +4421,7 @@ Query.prototype.updateOne = function(conditions, doc, options, callback) {
4409
4421
  * @param {Object} [doc] the update command
4410
4422
  * @param {Object} [options]
4411
4423
  * @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.
4412
- * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](http://mongoosejs.com/docs/guide.html#strict)
4424
+ * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
4413
4425
  * @param {Boolean} [options.upsert=false] if true, and no documents found, insert a new document
4414
4426
  * @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)
4415
4427
  * @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.
@@ -4417,8 +4429,8 @@ Query.prototype.updateOne = function(conditions, doc, options, callback) {
4417
4429
  * @return {Query} this
4418
4430
  * @see Model.update #model_Model.update
4419
4431
  * @see Query docs https://mongoosejs.com/docs/queries.html
4420
- * @see update http://docs.mongodb.org/manual/reference/method/db.collection.update/
4421
- * @see writeOpResult http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#~WriteOpResult
4432
+ * @see update https://docs.mongodb.org/manual/reference/method/db.collection.update/
4433
+ * @see writeOpResult https://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#~WriteOpResult
4422
4434
  * @see MongoDB docs https://docs.mongodb.com/manual/reference/command/update/#update-command-output
4423
4435
  * @api public
4424
4436
  */
@@ -4566,19 +4578,19 @@ Query.prototype.orFail = function(err) {
4566
4578
  case 'update':
4567
4579
  case 'updateMany':
4568
4580
  case 'updateOne':
4569
- if (get(res, 'modifiedCount') === 0) {
4581
+ if (res && res.modifiedCount === 0) {
4570
4582
  throw _orFailError(err, this);
4571
4583
  }
4572
4584
  break;
4573
4585
  case 'findOneAndDelete':
4574
4586
  case 'findOneAndRemove':
4575
- if (get(res, 'lastErrorObject.n') === 0) {
4587
+ if ((res && res.lastErrorObject && res.lastErrorObject.n) === 0) {
4576
4588
  throw _orFailError(err, this);
4577
4589
  }
4578
4590
  break;
4579
4591
  case 'findOneAndUpdate':
4580
4592
  case 'findOneAndReplace':
4581
- if (get(res, 'lastErrorObject.updatedExisting') === false) {
4593
+ if ((res && res.lastErrorObject && res.lastErrorObject.updatedExisting) === false) {
4582
4594
  throw _orFailError(err, this);
4583
4595
  }
4584
4596
  break;
@@ -4946,11 +4958,11 @@ Query.prototype.populate = function() {
4946
4958
  const readPref = this.options.readPreference;
4947
4959
 
4948
4960
  for (const populateOptions of res) {
4949
- if (readConcern != null && get(populateOptions, 'options.readConcern') == null) {
4961
+ if (readConcern != null && (populateOptions && populateOptions.options && populateOptions.options.readConcern) == null) {
4950
4962
  populateOptions.options = populateOptions.options || {};
4951
4963
  populateOptions.options.readConcern = readConcern;
4952
4964
  }
4953
- if (readPref != null && get(populateOptions, 'options.readPreference') == null) {
4965
+ if (readPref != null && (populateOptions && populateOptions.options && populateOptions.options.readPreference) == null) {
4954
4966
  populateOptions.options = populateOptions.options || {};
4955
4967
  populateOptions.options.readPreference = readPref;
4956
4968
  }
@@ -4962,7 +4974,7 @@ Query.prototype.populate = function() {
4962
4974
  if (opts.lean != null) {
4963
4975
  const lean = opts.lean;
4964
4976
  for (const populateOptions of res) {
4965
- if (get(populateOptions, 'options.lean') == null) {
4977
+ if ((populateOptions && populateOptions.options && populateOptions.options.lean) == null) {
4966
4978
  populateOptions.options = populateOptions.options || {};
4967
4979
  populateOptions.options.lean = lean;
4968
4980
  }
@@ -5087,7 +5099,7 @@ Query.prototype.cast = function(model, obj) {
5087
5099
  *
5088
5100
  * @param {Object} fields
5089
5101
  * @see https://github.com/Automattic/mongoose/issues/1091
5090
- * @see http://docs.mongodb.org/manual/reference/projection/elemMatch/
5102
+ * @see https://docs.mongodb.org/manual/reference/projection/elemMatch/
5091
5103
  * @api private
5092
5104
  */
5093
5105
 
@@ -5158,7 +5170,7 @@ Query.prototype._applyPaths = function applyPaths() {
5158
5170
  };
5159
5171
 
5160
5172
  /**
5161
- * Returns a wrapper around a [mongodb driver cursor](http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html).
5173
+ * Returns a wrapper around a [mongodb driver cursor](https://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html).
5162
5174
  * A QueryCursor exposes a Streams3 interface, as well as a `.next()` function.
5163
5175
  *
5164
5176
  * The `.cursor()` function triggers pre find hooks, but **not** post find hooks.
@@ -5251,7 +5263,7 @@ Query.prototype.maxscan = Query.base.maxScan;
5251
5263
  * @param {Object} [opts] options to set
5252
5264
  * @param {Boolean} [opts.awaitData] false by default. Set to true to keep the cursor open even if there's no data.
5253
5265
  * @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
5254
- * @see tailable http://docs.mongodb.org/manual/tutorial/create-tailable-cursor/
5266
+ * @see tailable https://docs.mongodb.org/manual/tutorial/create-tailable-cursor/
5255
5267
  * @api public
5256
5268
  */
5257
5269
 
@@ -5309,8 +5321,8 @@ Query.prototype.tailable = function(val, opts) {
5309
5321
  * @instance
5310
5322
  * @param {Object} [arg]
5311
5323
  * @return {Query} this
5312
- * @see $geometry http://docs.mongodb.org/manual/reference/operator/geometry/
5313
- * @see geoIntersects http://docs.mongodb.org/manual/reference/operator/geoIntersects/
5324
+ * @see $geometry https://docs.mongodb.org/manual/reference/operator/geometry/
5325
+ * @see geoIntersects https://docs.mongodb.org/manual/reference/operator/geoIntersects/
5314
5326
  * @api public
5315
5327
  */
5316
5328
 
@@ -5348,9 +5360,9 @@ Query.prototype.tailable = function(val, opts) {
5348
5360
  * @instance
5349
5361
  * @param {Object} object Must contain a `type` property which is a String and a `coordinates` property which is an Array. See the examples.
5350
5362
  * @return {Query} this
5351
- * @see $geometry http://docs.mongodb.org/manual/reference/operator/geometry/
5352
- * @see http://docs.mongodb.org/manual/release-notes/2.4/#new-geospatial-indexes-with-geojson-and-improved-spherical-geometry
5353
- * @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
5363
+ * @see $geometry https://docs.mongodb.org/manual/reference/operator/geometry/
5364
+ * @see https://docs.mongodb.org/manual/release-notes/2.4/#new-geospatial-indexes-with-geojson-and-improved-spherical-geometry
5365
+ * @see https://www.mongodb.org/display/DOCS/Geospatial+Indexing
5354
5366
  * @api public
5355
5367
  */
5356
5368
 
@@ -5372,10 +5384,10 @@ Query.prototype.tailable = function(val, opts) {
5372
5384
  * @param {String} [path]
5373
5385
  * @param {Object} val
5374
5386
  * @return {Query} this
5375
- * @see $near http://docs.mongodb.org/manual/reference/operator/near/
5376
- * @see $nearSphere http://docs.mongodb.org/manual/reference/operator/nearSphere/
5377
- * @see $maxDistance http://docs.mongodb.org/manual/reference/operator/maxDistance/
5378
- * @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
5387
+ * @see $near https://docs.mongodb.org/manual/reference/operator/near/
5388
+ * @see $nearSphere https://docs.mongodb.org/manual/reference/operator/nearSphere/
5389
+ * @see $maxDistance https://docs.mongodb.org/manual/reference/operator/maxDistance/
5390
+ * @see https://www.mongodb.org/display/DOCS/Geospatial+Indexing
5379
5391
  * @api public
5380
5392
  */
5381
5393
 
@@ -5454,9 +5466,9 @@ Query.prototype.near = function() {
5454
5466
  *
5455
5467
  * @deprecated
5456
5468
  * @see near() #query_Query-near
5457
- * @see $near http://docs.mongodb.org/manual/reference/operator/near/
5458
- * @see $nearSphere http://docs.mongodb.org/manual/reference/operator/nearSphere/
5459
- * @see $maxDistance http://docs.mongodb.org/manual/reference/operator/maxDistance/
5469
+ * @see $near https://docs.mongodb.org/manual/reference/operator/near/
5470
+ * @see $nearSphere https://docs.mongodb.org/manual/reference/operator/nearSphere/
5471
+ * @see $maxDistance https://docs.mongodb.org/manual/reference/operator/maxDistance/
5460
5472
  */
5461
5473
 
5462
5474
  Query.prototype.nearSphere = function() {
@@ -5510,8 +5522,8 @@ if (Symbol.asyncIterator != null) {
5510
5522
  * @param {String|Array} [path]
5511
5523
  * @param {Array|Object} [coordinatePairs...]
5512
5524
  * @return {Query} this
5513
- * @see $polygon http://docs.mongodb.org/manual/reference/operator/polygon/
5514
- * @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
5525
+ * @see $polygon https://docs.mongodb.org/manual/reference/operator/polygon/
5526
+ * @see https://www.mongodb.org/display/DOCS/Geospatial+Indexing
5515
5527
  * @api public
5516
5528
  */
5517
5529
 
@@ -5529,9 +5541,9 @@ if (Symbol.asyncIterator != null) {
5529
5541
  * @method box
5530
5542
  * @memberOf Query
5531
5543
  * @instance
5532
- * @see $box http://docs.mongodb.org/manual/reference/operator/box/
5544
+ * @see $box https://docs.mongodb.org/manual/reference/operator/box/
5533
5545
  * @see within() Query#within #query_Query-within
5534
- * @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
5546
+ * @see https://www.mongodb.org/display/DOCS/Geospatial+Indexing
5535
5547
  * @param {Object} val
5536
5548
  * @param [Array] Upper Right Coords
5537
5549
  * @return {Query} this
@@ -5574,10 +5586,10 @@ Query.prototype.box = function(ll, ur) {
5574
5586
  * @param {String} [path]
5575
5587
  * @param {Object} area
5576
5588
  * @return {Query} this
5577
- * @see $center http://docs.mongodb.org/manual/reference/operator/center/
5578
- * @see $centerSphere http://docs.mongodb.org/manual/reference/operator/centerSphere/
5579
- * @see $geoWithin http://docs.mongodb.org/manual/reference/operator/geoWithin/
5580
- * @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
5589
+ * @see $center https://docs.mongodb.org/manual/reference/operator/center/
5590
+ * @see $centerSphere https://docs.mongodb.org/manual/reference/operator/centerSphere/
5591
+ * @see $geoWithin https://docs.mongodb.org/manual/reference/operator/geoWithin/
5592
+ * @see https://www.mongodb.org/display/DOCS/Geospatial+Indexing
5581
5593
  * @api public
5582
5594
  */
5583
5595
 
@@ -5609,8 +5621,8 @@ Query.prototype.center = Query.base.circle;
5609
5621
  * @param {String} [path]
5610
5622
  * @param {Object} val
5611
5623
  * @return {Query} this
5612
- * @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
5613
- * @see $centerSphere http://docs.mongodb.org/manual/reference/operator/centerSphere/
5624
+ * @see https://www.mongodb.org/display/DOCS/Geospatial+Indexing
5625
+ * @see $centerSphere https://docs.mongodb.org/manual/reference/operator/centerSphere/
5614
5626
  * @api public
5615
5627
  */
5616
5628