mongoose 6.5.2 → 6.5.5

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 (95) hide show
  1. package/.mocharc.yml +2 -0
  2. package/dist/browser.umd.js +1148 -68091
  3. package/lib/aggregate.js +7 -7
  4. package/lib/browserDocument.js +1 -1
  5. package/lib/cast/boolean.js +1 -1
  6. package/lib/cast/number.js +1 -1
  7. package/lib/cast/string.js +1 -1
  8. package/lib/cast.js +3 -0
  9. package/lib/connection.js +19 -11
  10. package/lib/cursor/AggregationCursor.js +16 -5
  11. package/lib/cursor/QueryCursor.js +16 -5
  12. package/lib/document.js +31 -18
  13. package/lib/drivers/browser/objectid.js +2 -1
  14. package/lib/drivers/node-mongodb-native/ReadPreference.js +1 -1
  15. package/lib/drivers/node-mongodb-native/collection.js +6 -2
  16. package/lib/error/browserMissingSchema.js +1 -1
  17. package/lib/error/cast.js +2 -1
  18. package/lib/error/divergentArray.js +2 -1
  19. package/lib/error/missingSchema.js +2 -1
  20. package/lib/error/notFound.js +2 -1
  21. package/lib/error/overwriteModel.js +2 -1
  22. package/lib/error/strictPopulate.js +29 -0
  23. package/lib/error/validation.js +9 -7
  24. package/lib/error/validator.js +8 -4
  25. package/lib/helpers/clone.js +1 -1
  26. package/lib/helpers/discriminator/getConstructor.js +2 -1
  27. package/lib/helpers/discriminator/getDiscriminatorByValue.js +7 -6
  28. package/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +7 -6
  29. package/lib/helpers/document/compile.js +14 -2
  30. package/lib/helpers/document/getEmbeddedDiscriminatorPath.js +5 -1
  31. package/lib/helpers/get.js +2 -1
  32. package/lib/helpers/getConstructorName.js +2 -1
  33. package/lib/helpers/indexes/isIndexEqual.js +6 -6
  34. package/lib/helpers/isBsonType.js +2 -1
  35. package/lib/helpers/isMongooseObject.js +2 -2
  36. package/lib/helpers/isObject.js +1 -1
  37. package/lib/helpers/isSimpleValidator.js +1 -1
  38. package/lib/helpers/model/applyHooks.js +11 -0
  39. package/lib/helpers/model/applyMethods.js +11 -1
  40. package/lib/helpers/model/applyStatics.js +2 -1
  41. package/lib/helpers/model/castBulkWrite.js +7 -2
  42. package/lib/helpers/model/discriminator.js +3 -1
  43. package/lib/helpers/path/flattenObjectWithDottedPaths.js +3 -2
  44. package/lib/helpers/pluralize.js +1 -1
  45. package/lib/helpers/populate/assignRawDocsToIdStructure.js +5 -3
  46. package/lib/helpers/populate/assignVals.js +14 -3
  47. package/lib/helpers/populate/createPopulateQueryFilter.js +8 -2
  48. package/lib/helpers/populate/getModelsMapForPopulate.js +5 -4
  49. package/lib/helpers/populate/getSchemaTypes.js +3 -1
  50. package/lib/helpers/populate/markArraySubdocsPopulated.js +5 -1
  51. package/lib/helpers/projection/hasIncludedChildren.js +4 -1
  52. package/lib/helpers/projection/isPathExcluded.js +3 -2
  53. package/lib/helpers/projection/isSubpath.js +2 -1
  54. package/lib/helpers/query/applyQueryMiddleware.js +3 -2
  55. package/lib/helpers/query/castUpdate.js +14 -8
  56. package/lib/helpers/query/completeMany.js +3 -2
  57. package/lib/helpers/query/getEmbeddedDiscriminatorPath.js +7 -1
  58. package/lib/helpers/query/wrapThunk.js +3 -1
  59. package/lib/helpers/schema/getIndexes.js +7 -2
  60. package/lib/helpers/schema/getPath.js +4 -3
  61. package/lib/helpers/schema/idGetter.js +2 -1
  62. package/lib/helpers/setDefaultsOnInsert.js +15 -0
  63. package/lib/index.js +20 -12
  64. package/lib/model.js +219 -145
  65. package/lib/query.js +160 -65
  66. package/lib/queryhelpers.js +4 -4
  67. package/lib/schema/SubdocumentPath.js +1 -1
  68. package/lib/schema/array.js +2 -2
  69. package/lib/schema/date.js +2 -1
  70. package/lib/schema/documentarray.js +4 -3
  71. package/lib/schema/operators/helpers.js +2 -2
  72. package/lib/schema/operators/text.js +1 -1
  73. package/lib/schema/string.js +1 -1
  74. package/lib/schema.js +14 -5
  75. package/lib/schematype.js +17 -4
  76. package/lib/statemachine.js +13 -12
  77. package/lib/types/ArraySubdocument.js +13 -3
  78. package/lib/types/DocumentArray/methods/index.js +9 -5
  79. package/lib/types/array/methods/index.js +5 -4
  80. package/lib/types/map.js +3 -1
  81. package/lib/types/objectid.js +2 -2
  82. package/lib/types/subdocument.js +30 -8
  83. package/lib/utils.js +58 -31
  84. package/package.json +11 -11
  85. package/scripts/create-tarball.js +7 -0
  86. package/types/aggregate.d.ts +3 -3
  87. package/types/connection.d.ts +4 -4
  88. package/types/cursor.d.ts +1 -1
  89. package/types/document.d.ts +2 -2
  90. package/types/index.d.ts +13 -27
  91. package/types/indexes.d.ts +2 -2
  92. package/types/middlewares.d.ts +1 -1
  93. package/types/models.d.ts +14 -11
  94. package/types/pipelinestage.d.ts +1 -1
  95. package/types/query.d.ts +33 -16
package/lib/model.js CHANGED
@@ -119,11 +119,12 @@ function Model(doc, fields, skipId) {
119
119
  Document.call(this, doc, fields, skipId);
120
120
  }
121
121
 
122
- /*!
122
+ /**
123
123
  * Inherits from Document.
124
124
  *
125
125
  * All Model.prototype features are available on
126
126
  * top level (non-sub) documents.
127
+ * @api private
127
128
  */
128
129
 
129
130
  Model.prototype.__proto__ = Document.prototype;
@@ -222,7 +223,7 @@ Model.prototype.baseModelName;
222
223
 
223
224
  Model.events;
224
225
 
225
- /*!
226
+ /**
226
227
  * Compiled middleware for this model. Set in `applyHooks()`.
227
228
  *
228
229
  * @api private
@@ -538,12 +539,13 @@ Model.prototype.save = function(options, fn) {
538
539
 
539
540
  Model.prototype.$save = Model.prototype.save;
540
541
 
541
- /*!
542
+ /**
542
543
  * Determines whether versioning should be skipped for the given path
543
544
  *
544
545
  * @param {Document} self
545
546
  * @param {String} path
546
547
  * @return {Boolean} true if versioning should be skipped for the given path
548
+ * @api private
547
549
  */
548
550
  function shouldSkipVersioning(self, path) {
549
551
  const skipVersioning = self.$__schema.options.skipVersioning;
@@ -555,16 +557,17 @@ function shouldSkipVersioning(self, path) {
555
557
  return skipVersioning[path];
556
558
  }
557
559
 
558
- /*!
560
+ /**
559
561
  * Apply the operation to the delta (update) clause as
560
562
  * well as track versioning for our where clause.
561
563
  *
562
564
  * @param {Document} self
563
- * @param {Object} where
565
+ * @param {Object} where Unused
564
566
  * @param {Object} delta
565
567
  * @param {Object} data
566
568
  * @param {Mixed} val
567
- * @param {String} [operation]
569
+ * @param {String} [op]
570
+ * @api private
568
571
  */
569
572
 
570
573
  function operand(self, where, delta, data, val, op) {
@@ -623,7 +626,7 @@ function operand(self, where, delta, data, val, op) {
623
626
  }
624
627
  }
625
628
 
626
- /*!
629
+ /**
627
630
  * Compiles an update and where clause for a `val` with _atomics.
628
631
  *
629
632
  * @param {Document} self
@@ -631,6 +634,7 @@ function operand(self, where, delta, data, val, op) {
631
634
  * @param {Object} delta
632
635
  * @param {Object} data
633
636
  * @param {Array} value
637
+ * @api private
634
638
  */
635
639
 
636
640
  function handleAtomics(self, where, delta, data, value) {
@@ -797,14 +801,16 @@ Model.prototype.$__delta = function() {
797
801
  return [where, delta];
798
802
  };
799
803
 
800
- /*!
804
+ /**
801
805
  * Determine if array was populated with some form of filter and is now
802
806
  * being updated in a manner which could overwrite data unintentionally.
803
807
  *
804
808
  * @see https://github.com/Automattic/mongoose/issues/1334
805
809
  * @param {Document} doc
806
810
  * @param {String} path
811
+ * @param {Any} array
807
812
  * @return {String|undefined}
813
+ * @api private
808
814
  */
809
815
 
810
816
  function checkDivergentArray(doc, path, array) {
@@ -990,8 +996,14 @@ Model.prototype.remove = function remove(options, fn) {
990
996
  }, this.constructor.events);
991
997
  };
992
998
 
993
- /*!
999
+ /**
994
1000
  * Alias for remove
1001
+ *
1002
+ * @method $remove
1003
+ * @memberOf Model
1004
+ * @instance
1005
+ * @api public
1006
+ * @see Model.remove #model_Model-remove
995
1007
  */
996
1008
 
997
1009
  Model.prototype.$remove = Model.prototype.remove;
@@ -1240,8 +1252,9 @@ Model.discriminator = function(name, schema, options) {
1240
1252
  return d;
1241
1253
  };
1242
1254
 
1243
- /*!
1255
+ /**
1244
1256
  * Make sure `this` is a model
1257
+ * @api private
1245
1258
  */
1246
1259
 
1247
1260
  function _checkContext(ctx, fnName) {
@@ -1375,7 +1388,7 @@ Model.init = function init(callback) {
1375
1388
  * });
1376
1389
  *
1377
1390
  * @api public
1378
- * @param {Object} [options] see [MongoDB driver docs](https://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#createCollection)
1391
+ * @param {Object} [options] see [MongoDB driver docs](https://mongodb.github.io/node-mongodb-native/4.9/classes/Db.html#createCollection)
1379
1392
  * @param {Function} [callback]
1380
1393
  * @returns {Promise}
1381
1394
  */
@@ -1469,26 +1482,32 @@ Model.createCollection = function createCollection(options, callback) {
1469
1482
  Model.syncIndexes = function syncIndexes(options, callback) {
1470
1483
  _checkContext(this, 'syncIndexes');
1471
1484
 
1472
- callback = this.$handleCallbackError(callback);
1473
-
1474
- return this.db.base._promiseOrCallback(callback, cb => {
1475
- cb = this.$wrapCallback(cb);
1485
+ const model = this;
1486
+ callback = model.$handleCallbackError(callback);
1476
1487
 
1477
- this.createCollection(err => {
1488
+ return model.db.base._promiseOrCallback(callback, cb => {
1489
+ cb = model.$wrapCallback(cb);
1490
+ model.createCollection(err => {
1478
1491
  if (err != null && (err.name !== 'MongoServerError' || err.code !== 48)) {
1479
1492
  return cb(err);
1480
1493
  }
1481
- this.cleanIndexes((err, dropped) => {
1494
+ model.diffIndexes(err, (err, diffIndexesResult) => {
1482
1495
  if (err != null) {
1483
1496
  return cb(err);
1484
1497
  }
1485
- this.createIndexes(options, err => {
1498
+ model.cleanIndexes({ ...options, toDrop: diffIndexesResult.toDrop }, (err, dropped) => {
1486
1499
  if (err != null) {
1487
1500
  return cb(err);
1488
1501
  }
1489
- cb(null, dropped);
1502
+ model.createIndexes({ ...options, toCreate: diffIndexesResult.toCreate }, err => {
1503
+ if (err != null) {
1504
+ return cb(err);
1505
+ }
1506
+ cb(null, dropped);
1507
+ });
1490
1508
  });
1491
1509
  });
1510
+
1492
1511
  });
1493
1512
  }, this.events);
1494
1513
  };
@@ -1509,63 +1528,83 @@ Model.diffIndexes = function diffIndexes(options, callback) {
1509
1528
  callback = options;
1510
1529
  options = null;
1511
1530
  }
1512
- const toDrop = [];
1513
- const toCreate = [];
1514
- callback = this.$handleCallbackError(callback);
1515
- return this.db.base._promiseOrCallback(callback, cb => {
1516
- cb = this.$wrapCallback(cb);
1517
- this.listIndexes((err, dbIndexes) => {
1531
+
1532
+ const model = this;
1533
+
1534
+ callback = model.$handleCallbackError(callback);
1535
+
1536
+ return model.db.base._promiseOrCallback(callback, cb => {
1537
+ cb = model.$wrapCallback(cb);
1538
+ model.listIndexes((err, dbIndexes) => {
1518
1539
  if (dbIndexes === undefined) {
1519
1540
  dbIndexes = [];
1520
1541
  }
1521
- dbIndexes = getRelatedDBIndexes(this, dbIndexes);
1522
- const schemaIndexes = getRelatedSchemaIndexes(this, this.schema.indexes());
1542
+ dbIndexes = getRelatedDBIndexes(model, dbIndexes);
1523
1543
 
1524
- for (const dbIndex of dbIndexes) {
1525
- let found = false;
1526
- // Never try to drop `_id` index, MongoDB server doesn't allow it
1527
- if (isDefaultIdIndex(dbIndex)) {
1528
- continue;
1529
- }
1530
-
1531
- for (const [schemaIndexKeysObject, schemaIndexOptions] of schemaIndexes) {
1532
- const options = decorateDiscriminatorIndexOptions(this.schema, utils.clone(schemaIndexOptions));
1533
- applySchemaCollation(schemaIndexKeysObject, options, this.schema.options);
1544
+ const schema = model.schema;
1545
+ const schemaIndexes = getRelatedSchemaIndexes(model, schema.indexes());
1534
1546
 
1535
- if (isIndexEqual(schemaIndexKeysObject, options, dbIndex)) {
1536
- found = true;
1537
- }
1538
- }
1547
+ const toDrop = getIndexesToDrop(schema, schemaIndexes, dbIndexes);
1548
+ const toCreate = getIndexesToCreate(schema, schemaIndexes, dbIndexes);
1539
1549
 
1540
- if (!found) {
1541
- toDrop.push(dbIndex.name);
1542
- }
1543
- }
1544
- // Iterate through the indexes created on the schema and
1545
- // compare against the indexes in mongodb.
1546
- if (!options || options.toCreate !== false) {
1547
- for (const schemaIndex of schemaIndexes) {
1548
- let found = false;
1549
- const key = schemaIndex[0];
1550
- const options = decorateDiscriminatorIndexOptions(this.schema, utils.clone(schemaIndex[1]));
1551
- for (const index of dbIndexes) {
1552
- if (isDefaultIdIndex(index)) {
1553
- continue;
1554
- }
1555
- if (isIndexEqual(key, options, index)) {
1556
- found = true;
1557
- }
1558
- }
1559
- if (!found) {
1560
- toCreate.push(key);
1561
- }
1562
- }
1563
- }
1564
1550
  cb(null, { toDrop, toCreate });
1565
1551
  });
1566
1552
  });
1567
1553
  };
1568
1554
 
1555
+ function getIndexesToCreate(schema, schemaIndexes, dbIndexes) {
1556
+ const toCreate = [];
1557
+
1558
+ for (const [schemaIndexKeysObject, schemaIndexOptions] of schemaIndexes) {
1559
+ let found = false;
1560
+
1561
+ const options = decorateDiscriminatorIndexOptions(schema, utils.clone(schemaIndexOptions));
1562
+
1563
+ for (const index of dbIndexes) {
1564
+ if (isDefaultIdIndex(index)) {
1565
+ continue;
1566
+ }
1567
+ if (isIndexEqual(schemaIndexKeysObject, options, index)) {
1568
+ found = true;
1569
+ break;
1570
+ }
1571
+ }
1572
+
1573
+ if (!found) {
1574
+ toCreate.push(schemaIndexKeysObject);
1575
+ }
1576
+ }
1577
+
1578
+ return toCreate;
1579
+ }
1580
+
1581
+ function getIndexesToDrop(schema, schemaIndexes, dbIndexes) {
1582
+ const toDrop = [];
1583
+
1584
+ for (const dbIndex of dbIndexes) {
1585
+ let found = false;
1586
+ // Never try to drop `_id` index, MongoDB server doesn't allow it
1587
+ if (isDefaultIdIndex(dbIndex)) {
1588
+ continue;
1589
+ }
1590
+
1591
+ for (const [schemaIndexKeysObject, schemaIndexOptions] of schemaIndexes) {
1592
+ const options = decorateDiscriminatorIndexOptions(schema, utils.clone(schemaIndexOptions));
1593
+ applySchemaCollation(schemaIndexKeysObject, options, schema.options);
1594
+
1595
+ if (isIndexEqual(schemaIndexKeysObject, options, dbIndex)) {
1596
+ found = true;
1597
+ break;
1598
+ }
1599
+ }
1600
+
1601
+ if (!found) {
1602
+ toDrop.push(dbIndex.name);
1603
+ }
1604
+ }
1605
+
1606
+ return toDrop;
1607
+ }
1569
1608
  /**
1570
1609
  * Deletes all indexes that aren't defined in this model's schema. Used by
1571
1610
  * `syncIndexes()`.
@@ -1577,46 +1616,56 @@ Model.diffIndexes = function diffIndexes(options, callback) {
1577
1616
  * @api public
1578
1617
  */
1579
1618
 
1580
- Model.cleanIndexes = function cleanIndexes(callback) {
1619
+ Model.cleanIndexes = function cleanIndexes(options, callback) {
1581
1620
  _checkContext(this, 'cleanIndexes');
1621
+ const model = this;
1582
1622
 
1583
- callback = this.$handleCallbackError(callback);
1623
+ if (typeof options === 'function') {
1624
+ callback = options;
1625
+ options = null;
1626
+ }
1584
1627
 
1585
- return this.db.base._promiseOrCallback(callback, cb => {
1586
- const collection = this.$__collection;
1628
+ callback = model.$handleCallbackError(callback);
1587
1629
 
1588
- this.diffIndexes({ toCreate: false }, (err, res) => {
1630
+ return model.db.base._promiseOrCallback(callback, cb => {
1631
+ const collection = model.$__collection;
1632
+
1633
+ if (Array.isArray(options && options.toDrop)) {
1634
+ _dropIndexes(options.toDrop, collection, cb);
1635
+ return;
1636
+ }
1637
+ return model.diffIndexes((err, res) => {
1589
1638
  if (err != null) {
1590
1639
  return cb(err);
1591
1640
  }
1592
1641
 
1593
1642
  const toDrop = res.toDrop;
1594
-
1595
- if (toDrop.length === 0) {
1596
- return cb(null, []);
1597
- }
1598
-
1599
- dropIndexes(toDrop, cb);
1643
+ _dropIndexes(toDrop, collection, cb);
1600
1644
  });
1601
1645
 
1602
- function dropIndexes(toDrop, cb) {
1603
- let remaining = toDrop.length;
1604
- let error = false;
1605
- toDrop.forEach(indexName => {
1606
- collection.dropIndex(indexName, err => {
1607
- if (err != null) {
1608
- error = true;
1609
- return cb(err);
1610
- }
1611
- if (!error) {
1612
- --remaining || cb(null, toDrop);
1613
- }
1614
- });
1615
- });
1616
- }
1617
1646
  });
1618
1647
  };
1619
1648
 
1649
+ function _dropIndexes(toDrop, collection, cb) {
1650
+ if (toDrop.length === 0) {
1651
+ return cb(null, []);
1652
+ }
1653
+
1654
+ let remaining = toDrop.length;
1655
+ let error = false;
1656
+ toDrop.forEach(indexName => {
1657
+ collection.dropIndex(indexName, err => {
1658
+ if (err != null) {
1659
+ error = true;
1660
+ return cb(err);
1661
+ }
1662
+ if (!error) {
1663
+ --remaining || cb(null, toDrop);
1664
+ }
1665
+ });
1666
+ });
1667
+ }
1668
+
1620
1669
  /**
1621
1670
  * Lists the indexes currently defined in MongoDB. This may or may not be
1622
1671
  * the same as the indexes defined in your schema depending on whether you
@@ -1701,7 +1750,7 @@ Model.ensureIndexes = function ensureIndexes(options, callback) {
1701
1750
  };
1702
1751
 
1703
1752
  /**
1704
- * Similar to `ensureIndexes()`, except for it uses the [`createIndex`](https://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#createIndex)
1753
+ * Similar to `ensureIndexes()`, except for it uses the [`createIndex`](https://mongodb.github.io/node-mongodb-native/4.9/classes/Db.html#createIndex)
1705
1754
  * function.
1706
1755
  *
1707
1756
  * @param {Object} [options] internal options
@@ -1717,11 +1766,13 @@ Model.createIndexes = function createIndexes(options, callback) {
1717
1766
  callback = options;
1718
1767
  options = {};
1719
1768
  }
1769
+ callback = this.$handleCallbackError(callback);
1720
1770
  options = options || {};
1721
- options.createIndex = true;
1771
+
1722
1772
  return this.ensureIndexes(options, callback);
1723
1773
  };
1724
1774
 
1775
+
1725
1776
  /*!
1726
1777
  * ignore
1727
1778
  */
@@ -1837,17 +1888,18 @@ function _ensureIndexes(model, options, callback) {
1837
1888
 
1838
1889
  Model.schema;
1839
1890
 
1840
- /*!
1891
+ /**
1841
1892
  * Connection instance the model uses.
1842
1893
  *
1843
1894
  * @property db
1895
+ * @static
1844
1896
  * @api public
1845
1897
  * @memberOf Model
1846
1898
  */
1847
1899
 
1848
1900
  Model.db;
1849
1901
 
1850
- /*!
1902
+ /**
1851
1903
  * Collection the model uses.
1852
1904
  *
1853
1905
  * @property collection
@@ -2318,7 +2370,7 @@ Model.estimatedDocumentCount = function estimatedDocumentCount(options, callback
2318
2370
  * a full collection scan and **not** use any indexes.
2319
2371
  *
2320
2372
  * The `countDocuments()` function is similar to `count()`, but there are a
2321
- * [few operators that `countDocuments()` does not support](https://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#countDocuments).
2373
+ * [few operators that `countDocuments()` does not support](https://mongodb.github.io/node-mongodb-native/4.9/classes/Collection.html#countDocuments).
2322
2374
  * Below are the operators that `count()` supports but `countDocuments()` does not,
2323
2375
  * and the suggested replacement:
2324
2376
  *
@@ -2536,7 +2588,7 @@ Model.$where = function $where() {
2536
2588
  * @param {Object|String} [options.sort] if multiple docs are found by the conditions, sets the sort order to choose which doc to update.
2537
2589
  * @param {Boolean} [options.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
2538
2590
  * @param {Boolean} [options.setDefaultsOnInsert=true] 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
2539
- * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.3/interfaces/ModifyResult.html)
2591
+ * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html)
2540
2592
  * @param {Function} [callback]
2541
2593
  * @return {Query}
2542
2594
  * @see Tutorial /docs/tutorials/findoneandupdate.html
@@ -2583,8 +2635,9 @@ Model.findOneAndUpdate = function(conditions, update, options, callback) {
2583
2635
  return mq.findOneAndUpdate(conditions, update, options, callback);
2584
2636
  };
2585
2637
 
2586
- /*!
2638
+ /**
2587
2639
  * Decorate the update with a version key, if necessary
2640
+ * @api private
2588
2641
  */
2589
2642
 
2590
2643
  function _decorateUpdateWithVersionKey(update, options, versionKey) {
@@ -2662,7 +2715,7 @@ function _decorateUpdateWithVersionKey(update, options, versionKey) {
2662
2715
  * @param {Object|String} [options.sort] if multiple docs are found by the conditions, sets the sort order to choose which doc to update.
2663
2716
  * @param {Boolean} [options.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
2664
2717
  * @param {Boolean} [options.setDefaultsOnInsert=true] 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
2665
- * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.3/interfaces/ModifyResult.html)
2718
+ * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html)
2666
2719
  * @param {Boolean} [options.upsert=false] if true, and no documents found, insert a new document
2667
2720
  * @param {Boolean} [options.new=false] if true, return the modified document rather than the original
2668
2721
  * @param {Object|String} [options.select] sets the document fields to return.
@@ -2737,7 +2790,7 @@ Model.findByIdAndUpdate = function(id, update, options, callback) {
2737
2790
  * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
2738
2791
  * @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
2739
2792
  * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html).
2740
- * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.3/interfaces/ModifyResult.html)
2793
+ * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html)
2741
2794
  * @param {Object|String} [options.sort] if multiple docs are found by the conditions, sets the sort order to choose which doc to update.
2742
2795
  * @param {Object|String} [options.select] sets the document fields to return.
2743
2796
  * @param {Number} [options.maxTimeMS] puts a time limit on the query - requires mongodb >= 2.6.0
@@ -2838,7 +2891,7 @@ Model.findByIdAndDelete = function(id, options, callback) {
2838
2891
  * @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.
2839
2892
  * @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
2840
2893
  * @param {Object|String} [options.sort] if multiple docs are found by the conditions, sets the sort order to choose which doc to update.
2841
- * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.3/interfaces/ModifyResult.html)
2894
+ * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html)
2842
2895
  * @param {Object|String} [options.select] sets the document fields to return.
2843
2896
  * @param {Number} [options.maxTimeMS] puts a time limit on the query - requires mongodb >= 2.6.0
2844
2897
  * @param {Function} [callback]
@@ -2918,7 +2971,7 @@ Model.findOneAndReplace = function(filter, replacement, options, callback) {
2918
2971
  * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
2919
2972
  * @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
2920
2973
  * @param {Object|String} [options.sort] if multiple docs are found by the conditions, sets the sort order to choose which doc to update.
2921
- * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.3/interfaces/ModifyResult.html)
2974
+ * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html)
2922
2975
  * @param {Object|String} [options.select] sets the document fields to return.
2923
2976
  * @param {Number} [options.maxTimeMS] puts a time limit on the query - requires mongodb >= 2.6.0
2924
2977
  * @param {Function} [callback]
@@ -2981,7 +3034,7 @@ Model.findOneAndRemove = function(conditions, options, callback) {
2981
3034
  * @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html).
2982
3035
  * @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
2983
3036
  * @param {Object|String} [options.sort] if multiple docs are found by the conditions, sets the sort order to choose which doc to update.
2984
- * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.3/interfaces/ModifyResult.html)
3037
+ * @param {Boolean} [options.rawResult] if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html)
2985
3038
  * @param {Object|String} [options.select] sets the document fields to return.
2986
3039
  * @param {Function} [callback]
2987
3040
  * @return {Query}
@@ -3027,7 +3080,7 @@ Model.findByIdAndRemove = function(id, options, callback) {
3027
3080
  * await Character.create([{ name: 'Jean-Luc Picard' }], { session });
3028
3081
  *
3029
3082
  * @param {Array|Object} docs Documents to insert, as a spread or array
3030
- * @param {Object} [options] Options passed down to `save()`. To specify `options`, `docs` **must** be an array, not a spread.
3083
+ * @param {Object} [options] Options passed down to `save()`. To specify `options`, `docs` **must** be an array, not a spread. See [Model.save](#model_Model-save) for available options.
3031
3084
  * @param {Function} [callback] callback
3032
3085
  * @return {Promise}
3033
3086
  * @api public
@@ -3176,7 +3229,7 @@ Model.create = function create(doc, options, callback) {
3176
3229
  * await doc.remove();
3177
3230
  *
3178
3231
  * @param {Array} [pipeline]
3179
- * @param {Object} [options] see the [mongodb driver options](https://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#watch)
3232
+ * @param {Object} [options] see the [mongodb driver options](https://mongodb.github.io/node-mongodb-native/4.9/classes/Collection.html#watch)
3180
3233
  * @param {Boolean} [options.hydrate=false] if true and `fullDocument: 'updateLookup'` is set, Mongoose will automatically hydrate `fullDocument` into a fully fledged Mongoose document
3181
3234
  * @return {ChangeStream} mongoose-specific change stream wrapper, inherits from EventEmitter
3182
3235
  * @api public
@@ -3228,7 +3281,7 @@ Model.watch = function(pipeline, options) {
3228
3281
  * // secondary that is experiencing replication lag.
3229
3282
  * doc = await Person.findOne({ name: 'Ned Stark' }, null, { session, readPreference: 'secondary' });
3230
3283
  *
3231
- * @param {Object} [options] see the [mongodb driver options](https://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html#startSession)
3284
+ * @param {Object} [options] see the [mongodb driver options](https://mongodb.github.io/node-mongodb-native/4.9/classes/MongoClient.html#startSession)
3232
3285
  * @param {Boolean} [options.causalConsistency=true] set to false to disable causal consistency
3233
3286
  * @param {Function} [callback]
3234
3287
  * @return {Promise<ClientSession>} promise that resolves to a MongoDB driver `ClientSession`
@@ -3264,9 +3317,9 @@ Model.startSession = function() {
3264
3317
  * Movies.insertMany(arr, function(error, docs) {});
3265
3318
  *
3266
3319
  * @param {Array|Object|*} doc(s)
3267
- * @param {Object} [options] see the [mongodb driver options](https://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#insertMany)
3320
+ * @param {Object} [options] see the [mongodb driver options](https://mongodb.github.io/node-mongodb-native/4.9/classes/Collection.html#insertMany)
3268
3321
  * @param {Boolean} [options.ordered=true] if true, will fail fast on the first error encountered. If false, will insert all the documents it can and report errors later. An `insertMany()` with `ordered = false` is called an "unordered" `insertMany()`.
3269
- * @param {Boolean} [options.rawResult=false] if false, the returned promise resolves to the documents that passed mongoose document validation. If `true`, will return the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#~insertWriteOpCallback) with a `mongoose` property that contains `validationErrors` if this is an unordered `insertMany`.
3322
+ * @param {Boolean} [options.rawResult=false] if false, the returned promise resolves to the documents that passed mongoose document validation. If `true`, will return the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/InsertManyResult.html) with a `mongoose` property that contains `validationErrors` if this is an unordered `insertMany`.
3270
3323
  * @param {Boolean} [options.lean=false] if `true`, skips hydrating and validating the documents. This option is useful if you need the extra performance, but Mongoose won't validate the documents before inserting.
3271
3324
  * @param {Number} [options.limit=null] this limits the number of documents being processed (validation/casting) by mongoose in parallel, this does **NOT** send the documents in batches to MongoDB. Use this option if you're processing a large number of documents and your app is running out of memory.
3272
3325
  * @param {String|Object|Array} [options.populate=null] populates the result documents. This option is a no-op if `rawResult` is set.
@@ -3287,8 +3340,16 @@ Model.insertMany = function(arr, options, callback) {
3287
3340
  }, this.events);
3288
3341
  };
3289
3342
 
3290
- /*!
3343
+ /**
3291
3344
  * ignore
3345
+ *
3346
+ * @param {Array} arr
3347
+ * @param {Object} options
3348
+ * @param {Function} callback
3349
+ * @api private
3350
+ * @memberOf Model
3351
+ * @method $__insertMany
3352
+ * @static
3292
3353
  */
3293
3354
 
3294
3355
  Model.$__insertMany = function(arr, options, callback) {
@@ -3520,23 +3581,23 @@ function _setIsNew(doc, val) {
3520
3581
  *
3521
3582
  * @param {Array} ops
3522
3583
  * @param {Object} [ops.insertOne.document] The document to insert
3523
- * @param {Object} [opts.updateOne.filter] Update the first document that matches this filter
3524
- * @param {Object} [opts.updateOne.update] An object containing [update operators](https://docs.mongodb.com/manual/reference/operator/update/)
3525
- * @param {Boolean} [opts.updateOne.upsert=false] If true, insert a doc if none match
3526
- * @param {Boolean} [opts.updateOne.timestamps=true] If false, do not apply [timestamps](https://mongoosejs.com/docs/guide.html#timestamps) to the operation
3527
- * @param {Object} [opts.updateOne.collation] The [MongoDB collation](https://thecodebarbarian.com/a-nodejs-perspective-on-mongodb-34-collations) to use
3528
- * @param {Array} [opts.updateOne.arrayFilters] The [array filters](https://thecodebarbarian.com/a-nodejs-perspective-on-mongodb-36-array-filters.html) used in `update`
3529
- * @param {Object} [opts.updateMany.filter] Update all the documents that match this filter
3530
- * @param {Object} [opts.updateMany.update] An object containing [update operators](https://docs.mongodb.com/manual/reference/operator/update/)
3531
- * @param {Boolean} [opts.updateMany.upsert=false] If true, insert a doc if no documents match `filter`
3532
- * @param {Boolean} [opts.updateMany.timestamps=true] If false, do not apply [timestamps](https://mongoosejs.com/docs/guide.html#timestamps) to the operation
3533
- * @param {Object} [opts.updateMany.collation] The [MongoDB collation](https://thecodebarbarian.com/a-nodejs-perspective-on-mongodb-34-collations) to use
3534
- * @param {Array} [opts.updateMany.arrayFilters] The [array filters](https://thecodebarbarian.com/a-nodejs-perspective-on-mongodb-36-array-filters.html) used in `update`
3535
- * @param {Object} [opts.deleteOne.filter] Delete the first document that matches this filter
3536
- * @param {Object} [opts.deleteMany.filter] Delete all documents that match this filter
3537
- * @param {Object} [opts.replaceOne.filter] Replace the first document that matches this filter
3538
- * @param {Object} [opts.replaceOne.replacement] The replacement document
3539
- * @param {Boolean} [opts.replaceOne.upsert=false] If true, insert a doc if no documents match `filter`
3584
+ * @param {Object} [ops.updateOne.filter] Update the first document that matches this filter
3585
+ * @param {Object} [ops.updateOne.update] An object containing [update operators](https://docs.mongodb.com/manual/reference/operator/update/)
3586
+ * @param {Boolean} [ops.updateOne.upsert=false] If true, insert a doc if none match
3587
+ * @param {Boolean} [ops.updateOne.timestamps=true] If false, do not apply [timestamps](https://mongoosejs.com/docs/guide.html#timestamps) to the operation
3588
+ * @param {Object} [ops.updateOne.collation] The [MongoDB collation](https://thecodebarbarian.com/a-nodejs-perspective-on-mongodb-34-collations) to use
3589
+ * @param {Array} [ops.updateOne.arrayFilters] The [array filters](https://thecodebarbarian.com/a-nodejs-perspective-on-mongodb-36-array-filters.html) used in `update`
3590
+ * @param {Object} [ops.updateMany.filter] Update all the documents that match this filter
3591
+ * @param {Object} [ops.updateMany.update] An object containing [update operators](https://docs.mongodb.com/manual/reference/operator/update/)
3592
+ * @param {Boolean} [ops.updateMany.upsert=false] If true, insert a doc if no documents match `filter`
3593
+ * @param {Boolean} [ops.updateMany.timestamps=true] If false, do not apply [timestamps](https://mongoosejs.com/docs/guide.html#timestamps) to the operation
3594
+ * @param {Object} [ops.updateMany.collation] The [MongoDB collation](https://thecodebarbarian.com/a-nodejs-perspective-on-mongodb-34-collations) to use
3595
+ * @param {Array} [ops.updateMany.arrayFilters] The [array filters](https://thecodebarbarian.com/a-nodejs-perspective-on-mongodb-36-array-filters.html) used in `update`
3596
+ * @param {Object} [ops.deleteOne.filter] Delete the first document that matches this filter
3597
+ * @param {Object} [ops.deleteMany.filter] Delete all documents that match this filter
3598
+ * @param {Object} [ops.replaceOne.filter] Replace the first document that matches this filter
3599
+ * @param {Object} [ops.replaceOne.replacement] The replacement document
3600
+ * @param {Boolean} [ops.replaceOne.upsert=false] If true, insert a doc if no documents match `filter`
3540
3601
  * @param {Object} [options]
3541
3602
  * @param {Boolean} [options.ordered=true] If true, execute writes in order and stop at the first error. If false, execute writes in parallel and continue until all writes have either succeeded or errored.
3542
3603
  * @param {ClientSession} [options.session=null] The session associated with this bulk write. See [transactions docs](/docs/transactions.html).
@@ -3547,7 +3608,7 @@ function _setIsNew(doc, val) {
3547
3608
  * @param {Boolean} [options.bypassDocumentValidation=false] If true, disable [MongoDB server-side schema validation](https://docs.mongodb.com/manual/core/schema-validation/) for all writes in this bulk.
3548
3609
  * @param {Boolean} [options.strict=null] Overwrites the [`strict` option](/docs/guide.html#strict) on schema. If false, allows filtering and writing fields not defined in the schema for all writes in this bulk.
3549
3610
  * @param {Function} [callback] callback `function(error, bulkWriteOpResult) {}`
3550
- * @return {Promise} resolves to a [`BulkWriteOpResult`](https://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#~BulkWriteOpResult) if the operation succeeds
3611
+ * @return {Promise} resolves to a [`BulkWriteOpResult`](https://mongodb.github.io/node-mongodb-native/4.9/classes/BulkWriteResult.html) if the operation succeeds
3551
3612
  * @api public
3552
3613
  */
3553
3614
 
@@ -3960,10 +4021,10 @@ Model.hydrate = function(obj, projection, options) {
3960
4021
  * @param {Boolean} [options.setDefaultsOnInsert=false] `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.
3961
4022
  * @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.
3962
4023
  * @param {Boolean} [options.overwrite=false] By default, if you don't include any [update operators](https://docs.mongodb.com/manual/reference/operator/update/) in `doc`, Mongoose will wrap `doc` in `$set` for you. This prevents you from accidentally overwriting the document. This option tells Mongoose to skip adding `$set`.
3963
- * @param {Function} [callback] params are (error, [updateWriteOpResult](https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#~updateWriteOpResult))
4024
+ * @param {Function} [callback] params are (error, [updateWriteOpResult](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/UpdateResult.html))
3964
4025
  * @return {Query}
3965
4026
  * @see MongoDB docs https://docs.mongodb.com/manual/reference/command/update/#update-command-output
3966
- * @see writeOpResult https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#~updateWriteOpResult
4027
+ * @see UpdateResult https://mongodb.github.io/node-mongodb-native/4.9/interfaces/UpdateResult.html
3967
4028
  * @see Query docs https://mongoosejs.com/docs/queries.html
3968
4029
  * @api public
3969
4030
  */
@@ -4006,7 +4067,7 @@ Model.update = function update(conditions, doc, options, callback) {
4006
4067
  * @return {Query}
4007
4068
  * @see Query docs https://mongoosejs.com/docs/queries.html
4008
4069
  * @see MongoDB docs https://docs.mongodb.com/manual/reference/command/update/#update-command-output
4009
- * @see writeOpResult https://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#~WriteOpResult
4070
+ * @see UpdateResult https://mongodb.github.io/node-mongodb-native/4.9/interfaces/UpdateResult.html
4010
4071
  * @api public
4011
4072
  */
4012
4073
 
@@ -4047,7 +4108,7 @@ Model.updateMany = function updateMany(conditions, doc, options, callback) {
4047
4108
  * @return {Query}
4048
4109
  * @see Query docs https://mongoosejs.com/docs/queries.html
4049
4110
  * @see MongoDB docs https://docs.mongodb.com/manual/reference/command/update/#update-command-output
4050
- * @see writeOpResult https://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#~WriteOpResult
4111
+ * @see UpdateResult https://mongodb.github.io/node-mongodb-native/4.9/interfaces/UpdateResult.html
4051
4112
  * @api public
4052
4113
  */
4053
4114
 
@@ -4084,7 +4145,7 @@ Model.updateOne = function updateOne(conditions, doc, options, callback) {
4084
4145
  * @param {Function} [callback] `function(error, res) {}` where `res` has 3 properties: `n`, `nModified`, `ok`.
4085
4146
  * @return {Query}
4086
4147
  * @see Query docs https://mongoosejs.com/docs/queries.html
4087
- * @see writeOpResult https://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#~WriteOpResult
4148
+ * @see UpdateResult https://mongodb.github.io/node-mongodb-native/4.9/interfaces/UpdateResult.html
4088
4149
  * @return {Query}
4089
4150
  * @api public
4090
4151
  */
@@ -4100,9 +4161,10 @@ Model.replaceOne = function replaceOne(conditions, doc, options, callback) {
4100
4161
  return _update(this, 'replaceOne', conditions, doc, options, callback);
4101
4162
  };
4102
4163
 
4103
- /*!
4164
+ /**
4104
4165
  * Common code for `updateOne()`, `updateMany()`, `replaceOne()`, and `update()`
4105
4166
  * because they need to do the same thing
4167
+ * @api private
4106
4168
  */
4107
4169
 
4108
4170
  function _update(model, op, conditions, doc, options, callback) {
@@ -4129,7 +4191,7 @@ function _update(model, op, conditions, doc, options, callback) {
4129
4191
  /**
4130
4192
  * Executes a mapReduce command.
4131
4193
  *
4132
- * `opts` is an object specifying all mapReduce options as well as the map and reduce functions. All options are delegated to the driver implementation. See [node-mongodb-native mapReduce() documentation](https://mongodb.github.io/node-mongodb-native/api-generated/collection.html#mapreduce) for more detail about options.
4194
+ * `opts` is an object specifying all mapReduce options as well as the map and reduce functions. All options are delegated to the driver implementation. See [node-mongodb-native mapReduce() documentation](https://mongodb.github.io/node-mongodb-native/4.9/classes/Collection.html#mapReduce) for more detail about options.
4133
4195
  *
4134
4196
  * This function does not trigger any middleware.
4135
4197
  *
@@ -4513,13 +4575,14 @@ Model.populate = function(docs, paths, callback) {
4513
4575
  }, this.events);
4514
4576
  };
4515
4577
 
4516
- /*!
4578
+ /**
4517
4579
  * Populate helper
4518
4580
  *
4519
4581
  * @param {Model} model the model to use
4520
4582
  * @param {Document|Array} docs Either a single document or array of documents to populate.
4521
4583
  * @param {Object} paths
4522
- * @param {Function} [cb(err,doc)] Optional callback, executed upon completion. Receives `err` and the `doc(s)`.
4584
+ * @param {never} cache Unused
4585
+ * @param {Function} [callback] Optional callback, executed upon completion. Receives `err` and the `doc(s)`.
4523
4586
  * @return {Function}
4524
4587
  * @api private
4525
4588
  */
@@ -4704,7 +4767,7 @@ function populate(model, docs, options, callback) {
4704
4767
  */
4705
4768
 
4706
4769
  function _execPopulateQuery(mod, match, select, assignmentOpts, callback) {
4707
- const subPopulate = utils.clone(mod.options.populate);
4770
+ let subPopulate = utils.clone(mod.options.populate);
4708
4771
  const queryOptions = Object.assign({
4709
4772
  skip: mod.options.skip,
4710
4773
  limit: mod.options.limit,
@@ -4749,6 +4812,8 @@ function _execPopulateQuery(mod, match, select, assignmentOpts, callback) {
4749
4812
  if (mod.model.baseModelName != null) {
4750
4813
  if (Array.isArray(subPopulate)) {
4751
4814
  subPopulate.forEach(pop => { pop.strictPopulate = false; });
4815
+ } else if (typeof subPopulate === 'string') {
4816
+ subPopulate = { path: subPopulate, strictPopulate: false };
4752
4817
  } else {
4753
4818
  subPopulate.strictPopulate = false;
4754
4819
  }
@@ -4888,7 +4953,7 @@ function _assign(model, vals, mod, assignmentOpts) {
4888
4953
  });
4889
4954
  }
4890
4955
 
4891
- /*!
4956
+ /**
4892
4957
  * Compiler utility.
4893
4958
  *
4894
4959
  * @param {String|Function} name model name or class extending Model
@@ -4896,6 +4961,7 @@ function _assign(model, vals, mod, assignmentOpts) {
4896
4961
  * @param {String} collectionName
4897
4962
  * @param {Connection} connection
4898
4963
  * @param {Mongoose} base mongoose instance
4964
+ * @api private
4899
4965
  */
4900
4966
 
4901
4967
  Model.compile = function compile(name, schema, collectionName, connection, base) {
@@ -5004,11 +5070,12 @@ Model.compile = function compile(name, schema, collectionName, connection, base)
5004
5070
  return model;
5005
5071
  };
5006
5072
 
5007
- /*!
5073
+ /**
5008
5074
  * Register custom query methods for this model
5009
5075
  *
5010
5076
  * @param {Model} model
5011
5077
  * @param {Schema} schema
5078
+ * @api private
5012
5079
  */
5013
5080
 
5014
5081
  function applyQueryMethods(model, methods) {
@@ -5017,13 +5084,17 @@ function applyQueryMethods(model, methods) {
5017
5084
  }
5018
5085
  }
5019
5086
 
5020
- /*!
5087
+ /**
5021
5088
  * Subclass this model with `conn`, `schema`, and `collection` settings.
5022
5089
  *
5023
5090
  * @param {Connection} conn
5024
5091
  * @param {Schema} [schema]
5025
5092
  * @param {String} [collection]
5026
5093
  * @return {Model}
5094
+ * @api private
5095
+ * @memberOf Model
5096
+ * @static
5097
+ * @method __subclass
5027
5098
  */
5028
5099
 
5029
5100
  Model.__subclass = function subclass(conn, schema, collection) {
@@ -5100,8 +5171,14 @@ Model.$handleCallbackError = function(callback) {
5100
5171
  };
5101
5172
  };
5102
5173
 
5103
- /*!
5174
+ /**
5104
5175
  * ignore
5176
+ *
5177
+ * @param {Function} callback
5178
+ * @api private
5179
+ * @method $wrapCallback
5180
+ * @memberOf Model
5181
+ * @static
5105
5182
  */
5106
5183
 
5107
5184
  Model.$wrapCallback = function(callback) {
@@ -5138,10 +5215,7 @@ Model.inspect = function() {
5138
5215
  };
5139
5216
 
5140
5217
  if (util.inspect.custom) {
5141
- /*!
5142
- * Avoid Node deprecation warning DEP0079
5143
- */
5144
-
5218
+ // Avoid Node deprecation warning DEP0079
5145
5219
  Model[util.inspect.custom] = Model.inspect;
5146
5220
  }
5147
5221