mongoose 9.2.2 → 9.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/lib/aggregate.js +41 -41
  2. package/lib/cast/bigint.js +2 -2
  3. package/lib/cast/boolean.js +3 -3
  4. package/lib/cast/double.js +2 -2
  5. package/lib/cast/int32.js +2 -2
  6. package/lib/cast/number.js +2 -2
  7. package/lib/cast/string.js +2 -2
  8. package/lib/cast.js +6 -6
  9. package/lib/collection.js +4 -4
  10. package/lib/connection.js +58 -58
  11. package/lib/cursor/aggregationCursor.js +6 -6
  12. package/lib/cursor/queryCursor.js +7 -7
  13. package/lib/document.js +176 -176
  14. package/lib/drivers/node-mongodb-native/collection.js +2 -2
  15. package/lib/drivers/node-mongodb-native/connection.js +8 -8
  16. package/lib/error/cast.js +2 -2
  17. package/lib/error/createCollectionsError.js +2 -2
  18. package/lib/error/divergentArray.js +1 -1
  19. package/lib/error/eachAsyncMultiError.js +1 -1
  20. package/lib/error/index.js +2 -2
  21. package/lib/error/invalidSchemaOption.js +1 -1
  22. package/lib/error/missingSchema.js +1 -1
  23. package/lib/error/objectParameter.js +3 -3
  24. package/lib/error/overwriteModel.js +1 -1
  25. package/lib/error/setOptionError.js +3 -3
  26. package/lib/error/strict.js +3 -3
  27. package/lib/error/strictPopulate.js +2 -2
  28. package/lib/error/syncIndexes.js +2 -2
  29. package/lib/error/validation.js +2 -2
  30. package/lib/error/validator.js +1 -1
  31. package/lib/error/version.js +2 -2
  32. package/lib/helpers/buildMiddlewareFilter.js +2 -2
  33. package/lib/helpers/clone.js +4 -4
  34. package/lib/helpers/createJSONSchemaTypeDefinition.js +4 -4
  35. package/lib/helpers/cursor/eachAsync.js +3 -3
  36. package/lib/helpers/discriminator/getDiscriminatorByValue.js +1 -1
  37. package/lib/helpers/discriminator/mergeDiscriminatorSchema.js +3 -3
  38. package/lib/helpers/document/applyTimestamps.js +9 -9
  39. package/lib/helpers/document/applyVirtuals.js +6 -6
  40. package/lib/helpers/document/compile.js +10 -10
  41. package/lib/helpers/document/getDeepestSubdocumentForPath.js +2 -2
  42. package/lib/helpers/document/getEmbeddedDiscriminatorPath.js +2 -2
  43. package/lib/helpers/indexes/isIndexEqual.js +3 -3
  44. package/lib/helpers/indexes/isIndexSpecEqual.js +3 -3
  45. package/lib/helpers/isMongooseObject.js +1 -1
  46. package/lib/helpers/isObject.js +2 -2
  47. package/lib/helpers/isSimpleValidator.js +2 -2
  48. package/lib/helpers/minimize.js +2 -2
  49. package/lib/helpers/model/applyHooks.js +1 -1
  50. package/lib/helpers/model/castBulkWrite.js +2 -2
  51. package/lib/helpers/pluralize.js +1 -1
  52. package/lib/helpers/populate/assignRawDocsToIdStructure.js +2 -2
  53. package/lib/helpers/populate/assignVals.js +6 -6
  54. package/lib/helpers/populate/createPopulateQueryFilter.js +2 -2
  55. package/lib/helpers/populate/getModelsMapForPopulate.js +12 -12
  56. package/lib/helpers/populate/getSchemaTypes.js +1 -1
  57. package/lib/helpers/populate/markArraySubdocsPopulated.js +1 -1
  58. package/lib/helpers/populate/setPopulatedVirtualValue.js +5 -5
  59. package/lib/helpers/projection/hasIncludedChildren.js +1 -1
  60. package/lib/helpers/projection/isPathExcluded.js +3 -3
  61. package/lib/helpers/projection/isSubpath.js +1 -1
  62. package/lib/helpers/query/castUpdate.js +14 -14
  63. package/lib/helpers/query/getEmbeddedDiscriminatorPath.js +4 -4
  64. package/lib/helpers/query/handleImmutable.js +6 -6
  65. package/lib/helpers/schema/getIndexes.js +1 -1
  66. package/lib/helpers/schema/getSubdocumentStrictValue.js +1 -1
  67. package/lib/helpers/setDefaultsOnInsert.js +3 -3
  68. package/lib/helpers/update/modifiedPaths.js +2 -2
  69. package/lib/helpers/updateValidators.js +2 -2
  70. package/lib/model.js +263 -263
  71. package/lib/mongoose.js +54 -54
  72. package/lib/options/schemaArrayOptions.js +2 -2
  73. package/lib/options/schemaBufferOptions.js +1 -1
  74. package/lib/options/schemaNumberOptions.js +3 -3
  75. package/lib/options/schemaObjectIdOptions.js +2 -2
  76. package/lib/options/schemaStringOptions.js +6 -6
  77. package/lib/options/schemaTypeOptions.js +13 -13
  78. package/lib/options/virtualOptions.js +11 -11
  79. package/lib/query.js +222 -222
  80. package/lib/queryHelpers.js +4 -4
  81. package/lib/schema/array.js +18 -18
  82. package/lib/schema/bigint.js +13 -13
  83. package/lib/schema/boolean.js +13 -13
  84. package/lib/schema/buffer.js +14 -14
  85. package/lib/schema/date.js +16 -16
  86. package/lib/schema/decimal128.js +13 -13
  87. package/lib/schema/documentArray.js +15 -15
  88. package/lib/schema/documentArrayElement.js +5 -6
  89. package/lib/schema/double.js +12 -12
  90. package/lib/schema/int32.js +13 -13
  91. package/lib/schema/map.js +10 -10
  92. package/lib/schema/mixed.js +10 -10
  93. package/lib/schema/number.js +18 -18
  94. package/lib/schema/objectId.js +14 -14
  95. package/lib/schema/operators/text.js +3 -3
  96. package/lib/schema/string.js +17 -17
  97. package/lib/schema/subdocument.js +13 -13
  98. package/lib/schema/union.js +3 -3
  99. package/lib/schema/uuid.js +16 -16
  100. package/lib/schema.js +76 -76
  101. package/lib/schemaType.js +62 -62
  102. package/lib/stateMachine.js +5 -8
  103. package/lib/types/array/index.js +1 -1
  104. package/lib/types/array/methods/index.js +12 -12
  105. package/lib/types/arraySubdocument.js +8 -8
  106. package/lib/types/buffer.js +4 -4
  107. package/lib/types/documentArray/index.js +1 -1
  108. package/lib/types/documentArray/methods/index.js +5 -5
  109. package/lib/types/map.js +3 -3
  110. package/lib/types/subdocument.js +11 -11
  111. package/lib/utils.js +45 -45
  112. package/lib/virtualType.js +18 -18
  113. package/package.json +8 -5
  114. package/types/index.d.ts +16 -15
  115. package/types/inferschematype.d.ts +10 -0
  116. package/types/models.d.ts +8 -5
  117. package/types/schemaoptions.d.ts +1 -1
  118. package/types/virtuals.d.ts +10 -10
package/lib/mongoose.js CHANGED
@@ -56,7 +56,7 @@ const { AsyncLocalStorage } = require('async_hooks');
56
56
  * const m = new mongoose.Mongoose();
57
57
  *
58
58
  * @api public
59
- * @param {Object} options see [`Mongoose#set()` docs](https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.set())
59
+ * @param {object} options see [`Mongoose#set()` docs](https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.set())
60
60
  */
61
61
  function Mongoose(options) {
62
62
  this.connections = [];
@@ -247,9 +247,9 @@ Mongoose.prototype.setDriver = function setDriver(driver) {
247
247
  * - `translateAliases`: `false` by default. If `true`, Mongoose will automatically translate aliases to their original paths before sending the query to MongoDB.
248
248
  * - `updatePipeline`: `false` by default. If `true`, allows passing update pipelines (arrays) to update operations by default without explicitly setting `updatePipeline: true` in each query.
249
249
  *
250
- * @param {String|Object} key The name of the option or a object of multiple key-value pairs
251
- * @param {String|Function|Boolean} value The value of the option, unused if "key" is a object
252
- * @returns {Mongoose} The used Mongoose instnace
250
+ * @param {string|object} key The name of the option or a object of multiple key-value pairs
251
+ * @param {string|Function|boolean} value The value of the option, unused if "key" is a object
252
+ * @returns {Mongoose} The used Mongoose instance
253
253
  * @api public
254
254
  */
255
255
 
@@ -350,7 +350,7 @@ Mongoose.prototype.set = function getsetOptions(key, value) {
350
350
  *
351
351
  * mongoose.get('test') // returns the 'test' value
352
352
  *
353
- * @param {String} key
353
+ * @param {string} key
354
354
  * @method get
355
355
  * @api public
356
356
  */
@@ -385,18 +385,18 @@ Mongoose.prototype.get = Mongoose.prototype.set;
385
385
  * db = mongoose.createConnection();
386
386
  * await db.openUri('mongodb://127.0.0.1:27017/database');
387
387
  *
388
- * @param {String} uri mongodb URI to connect to
389
- * @param {Object} [options] passed down to the [MongoDB driver's `connect()` function](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/MongoClientOptions.html), except for 4 mongoose-specific options explained below.
390
- * @param {Boolean} [options.bufferCommands=true] Mongoose specific option. Set to false to [disable buffering](https://mongoosejs.com/docs/faq.html#callback_never_executes) on all models associated with this connection.
391
- * @param {String} [options.dbName] The name of the database you want to use. If not provided, Mongoose uses the database name from connection string.
392
- * @param {String} [options.user] username for authentication, equivalent to `options.auth.username`. Maintained for backwards compatibility.
393
- * @param {String} [options.pass] password for authentication, equivalent to `options.auth.password`. Maintained for backwards compatibility.
394
- * @param {Boolean} [options.autoIndex=true] Mongoose-specific option. Set to false to disable automatic index creation for all models associated with this connection.
388
+ * @param {string} uri mongodb URI to connect to
389
+ * @param {object} [options] passed down to the [MongoDB driver's `connect()` function](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/MongoClientOptions.html), except for 4 mongoose-specific options explained below.
390
+ * @param {boolean} [options.bufferCommands=true] Mongoose specific option. Set to false to [disable buffering](https://mongoosejs.com/docs/faq.html#callback_never_executes) on all models associated with this connection.
391
+ * @param {string} [options.dbName] The name of the database you want to use. If not provided, Mongoose uses the database name from connection string.
392
+ * @param {string} [options.user] username for authentication, equivalent to `options.auth.username`. Maintained for backwards compatibility.
393
+ * @param {string} [options.pass] password for authentication, equivalent to `options.auth.password`. Maintained for backwards compatibility.
394
+ * @param {boolean} [options.autoIndex=true] Mongoose-specific option. Set to false to disable automatic index creation for all models associated with this connection.
395
395
  * @param {Class} [options.promiseLibrary] Sets the [underlying driver's promise library](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/MongoClientOptions.html#promiseLibrary).
396
- * @param {Number} [options.maxPoolSize=5] The maximum number of sockets the MongoDB driver will keep open for this connection. Keep in mind that MongoDB only allows one operation per socket at a time, so you may want to increase this if you find you have a few slow queries that are blocking faster queries from proceeding. See [Slow Trains in MongoDB and Node.js](https://thecodebarbarian.com/slow-trains-in-mongodb-and-nodejs).
397
- * @param {Number} [options.minPoolSize=1] The minimum number of sockets the MongoDB driver will keep open for this connection. Keep in mind that MongoDB only allows one operation per socket at a time, so you may want to increase this if you find you have a few slow queries that are blocking faster queries from proceeding. See [Slow Trains in MongoDB and Node.js](https://thecodebarbarian.com/slow-trains-in-mongodb-and-nodejs).
398
- * @param {Number} [options.socketTimeoutMS=0] How long the MongoDB driver will wait before killing a socket due to inactivity _after initial connection_. Defaults to 0, which means Node.js will not time out the socket due to inactivity. A socket may be inactive because of either no activity or a long-running operation. This option is passed to [Node.js `socket#setTimeout()` function](https://nodejs.org/api/net.html#net_socket_settimeout_timeout_callback) after the MongoDB driver successfully completes.
399
- * @param {Number} [options.family=0] Passed transparently to [Node.js' `dns.lookup()`](https://nodejs.org/api/dns.html#dns_dns_lookup_hostname_options_callback) function. May be either `0`, `4`, or `6`. `4` means use IPv4 only, `6` means use IPv6 only, `0` means try both.
396
+ * @param {number} [options.maxPoolSize=5] The maximum number of sockets the MongoDB driver will keep open for this connection. Keep in mind that MongoDB only allows one operation per socket at a time, so you may want to increase this if you find you have a few slow queries that are blocking faster queries from proceeding. See [Slow Trains in MongoDB and Node.js](https://thecodebarbarian.com/slow-trains-in-mongodb-and-nodejs).
397
+ * @param {number} [options.minPoolSize=1] The minimum number of sockets the MongoDB driver will keep open for this connection. Keep in mind that MongoDB only allows one operation per socket at a time, so you may want to increase this if you find you have a few slow queries that are blocking faster queries from proceeding. See [Slow Trains in MongoDB and Node.js](https://thecodebarbarian.com/slow-trains-in-mongodb-and-nodejs).
398
+ * @param {number} [options.socketTimeoutMS=0] How long the MongoDB driver will wait before killing a socket due to inactivity _after initial connection_. Defaults to 0, which means Node.js will not time out the socket due to inactivity. A socket may be inactive because of either no activity or a long-running operation. This option is passed to [Node.js `socket#setTimeout()` function](https://nodejs.org/api/net.html#net_socket_settimeout_timeout_callback) after the MongoDB driver successfully completes.
399
+ * @param {number} [options.family=0] Passed transparently to [Node.js' `dns.lookup()`](https://nodejs.org/api/dns.html#dns_dns_lookup_hostname_options_callback) function. May be either `0`, `4`, or `6`. `4` means use IPv4 only, `6` means use IPv6 only, `0` means try both.
400
400
  * @return {Connection} the created Connection object. Connections are not thenable, so you can't do `await mongoose.createConnection()`. To await use `mongoose.createConnection(uri).asPromise()` instead.
401
401
  * @api public
402
402
  */
@@ -436,22 +436,22 @@ Mongoose.prototype.createConnection = function createConnection(uri, options) {
436
436
  * const uri = 'mongodb://nonexistent.domain:27000';
437
437
  * await mongoose.connect(uri);
438
438
  *
439
- * @param {String} uri mongodb URI to connect to
440
- * @param {Object} [options] passed down to the [MongoDB driver's `connect()` function](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/MongoClientOptions.html), except for 4 mongoose-specific options explained below.
441
- * @param {Boolean} [options.bufferCommands=true] Mongoose specific option. Set to false to [disable buffering](https://mongoosejs.com/docs/faq.html#callback_never_executes) on all models associated with this connection.
442
- * @param {Number} [options.bufferTimeoutMS=10000] Mongoose specific option. If `bufferCommands` is true, Mongoose will throw an error after `bufferTimeoutMS` if the operation is still buffered.
443
- * @param {String} [options.dbName] The name of the database we want to use. If not provided, use database name from connection string.
444
- * @param {String} [options.user] username for authentication, equivalent to `options.auth.username`. Maintained for backwards compatibility.
445
- * @param {String} [options.pass] password for authentication, equivalent to `options.auth.password`. Maintained for backwards compatibility.
446
- * @param {Number} [options.maxPoolSize=100] The maximum number of sockets the MongoDB driver will keep open for this connection. Keep in mind that MongoDB only allows one operation per socket at a time, so you may want to increase this if you find you have a few slow queries that are blocking faster queries from proceeding. See [Slow Trains in MongoDB and Node.js](https://thecodebarbarian.com/slow-trains-in-mongodb-and-nodejs).
447
- * @param {Number} [options.minPoolSize=0] The minimum number of sockets the MongoDB driver will keep open for this connection.
448
- * @param {Number} [options.serverSelectionTimeoutMS] If `useUnifiedTopology = true`, the MongoDB driver will try to find a server to send any given operation to, and keep retrying for `serverSelectionTimeoutMS` milliseconds before erroring out. If not set, the MongoDB driver defaults to using `30000` (30 seconds).
449
- * @param {Number} [options.heartbeatFrequencyMS] If `useUnifiedTopology = true`, the MongoDB driver sends a heartbeat every `heartbeatFrequencyMS` to check on the status of the connection. A heartbeat is subject to `serverSelectionTimeoutMS`, so the MongoDB driver will retry failed heartbeats for up to 30 seconds by default. Mongoose only emits a `'disconnected'` event after a heartbeat has failed, so you may want to decrease this setting to reduce the time between when your server goes down and when Mongoose emits `'disconnected'`. We recommend you do **not** set this setting below 1000, too many heartbeats can lead to performance degradation.
450
- * @param {Boolean} [options.autoIndex=true] Mongoose-specific option. Set to false to disable automatic index creation for all models associated with this connection.
439
+ * @param {string} uri mongodb URI to connect to
440
+ * @param {object} [options] passed down to the [MongoDB driver's `connect()` function](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/MongoClientOptions.html), except for 4 mongoose-specific options explained below.
441
+ * @param {boolean} [options.bufferCommands=true] Mongoose specific option. Set to false to [disable buffering](https://mongoosejs.com/docs/faq.html#callback_never_executes) on all models associated with this connection.
442
+ * @param {number} [options.bufferTimeoutMS=10000] Mongoose specific option. If `bufferCommands` is true, Mongoose will throw an error after `bufferTimeoutMS` if the operation is still buffered.
443
+ * @param {string} [options.dbName] The name of the database we want to use. If not provided, use database name from connection string.
444
+ * @param {string} [options.user] username for authentication, equivalent to `options.auth.username`. Maintained for backwards compatibility.
445
+ * @param {string} [options.pass] password for authentication, equivalent to `options.auth.password`. Maintained for backwards compatibility.
446
+ * @param {number} [options.maxPoolSize=100] The maximum number of sockets the MongoDB driver will keep open for this connection. Keep in mind that MongoDB only allows one operation per socket at a time, so you may want to increase this if you find you have a few slow queries that are blocking faster queries from proceeding. See [Slow Trains in MongoDB and Node.js](https://thecodebarbarian.com/slow-trains-in-mongodb-and-nodejs).
447
+ * @param {number} [options.minPoolSize=0] The minimum number of sockets the MongoDB driver will keep open for this connection.
448
+ * @param {number} [options.serverSelectionTimeoutMS] If `useUnifiedTopology = true`, the MongoDB driver will try to find a server to send any given operation to, and keep retrying for `serverSelectionTimeoutMS` milliseconds before erroring out. If not set, the MongoDB driver defaults to using `30000` (30 seconds).
449
+ * @param {number} [options.heartbeatFrequencyMS] If `useUnifiedTopology = true`, the MongoDB driver sends a heartbeat every `heartbeatFrequencyMS` to check on the status of the connection. A heartbeat is subject to `serverSelectionTimeoutMS`, so the MongoDB driver will retry failed heartbeats for up to 30 seconds by default. Mongoose only emits a `'disconnected'` event after a heartbeat has failed, so you may want to decrease this setting to reduce the time between when your server goes down and when Mongoose emits `'disconnected'`. We recommend you do **not** set this setting below 1000, too many heartbeats can lead to performance degradation.
450
+ * @param {boolean} [options.autoIndex=true] Mongoose-specific option. Set to false to disable automatic index creation for all models associated with this connection.
451
451
  * @param {Class} [options.promiseLibrary] Sets the [underlying driver's promise library](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/MongoClientOptions.html#promiseLibrary).
452
- * @param {Number} [options.socketTimeoutMS=0] How long the MongoDB driver will wait before killing a socket due to inactivity _after initial connection_. A socket may be inactive because of either no activity or a long-running operation. `socketTimeoutMS` defaults to 0, which means Node.js will not time out the socket due to inactivity. This option is passed to [Node.js `socket#setTimeout()` function](https://nodejs.org/api/net.html#net_socket_settimeout_timeout_callback) after the MongoDB driver successfully completes.
453
- * @param {Number} [options.family=0] Passed transparently to [Node.js' `dns.lookup()`](https://nodejs.org/api/dns.html#dns_dns_lookup_hostname_options_callback) function. May be either `0`, `4`, or `6`. `4` means use IPv4 only, `6` means use IPv6 only, `0` means try both.
454
- * @param {Boolean} [options.autoCreate=false] Set to `true` to make Mongoose automatically call `createCollection()` on every model created on this connection.
452
+ * @param {number} [options.socketTimeoutMS=0] How long the MongoDB driver will wait before killing a socket due to inactivity _after initial connection_. A socket may be inactive because of either no activity or a long-running operation. `socketTimeoutMS` defaults to 0, which means Node.js will not time out the socket due to inactivity. This option is passed to [Node.js `socket#setTimeout()` function](https://nodejs.org/api/net.html#net_socket_settimeout_timeout_callback) after the MongoDB driver successfully completes.
453
+ * @param {number} [options.family=0] Passed transparently to [Node.js' `dns.lookup()`](https://nodejs.org/api/dns.html#dns_dns_lookup_hostname_options_callback) function. May be either `0`, `4`, or `6`. `4` means use IPv4 only, `6` means use IPv6 only, `0` means try both.
454
+ * @param {boolean} [options.autoCreate=false] Set to `true` to make Mongoose automatically call `createCollection()` on every model created on this connection.
455
455
  * @see Mongoose#createConnection https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.createConnection()
456
456
  * @api public
457
457
  * @return {Promise} resolves to `this` if connection succeeded
@@ -501,8 +501,8 @@ Mongoose.prototype.disconnect = async function disconnect() {
501
501
  * Sessions are scoped to a connection, so calling `mongoose.startSession()`
502
502
  * starts a session on the [default mongoose connection](https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.connection).
503
503
  *
504
- * @param {Object} [options] see the [mongodb driver options](https://mongodb.github.io/node-mongodb-native/4.9/classes/MongoClient.html#startSession)
505
- * @param {Boolean} [options.causalConsistency=true] set to false to disable causal consistency
504
+ * @param {object} [options] see the [mongodb driver options](https://mongodb.github.io/node-mongodb-native/4.9/classes/MongoClient.html#startSession)
505
+ * @param {boolean} [options.causalConsistency=true] set to false to disable causal consistency
506
506
  * @return {Promise<ClientSession>} promise that resolves to a MongoDB driver `ClientSession`
507
507
  * @api public
508
508
  */
@@ -575,11 +575,11 @@ Mongoose.prototype.pluralize = function pluralize(fn) {
575
575
  * const collectionName = 'actor';
576
576
  * const M = mongoose.model('Actor', schema, collectionName);
577
577
  *
578
- * @param {String|Function} name model name or class extending Model
578
+ * @param {string|Function} name model name or class extending Model
579
579
  * @param {Schema} [schema] the schema to use.
580
- * @param {String} [collection] name (optional, inferred from model name)
581
- * @param {Object} [options]
582
- * @param {Boolean} [options.overwriteModels=false] If true, overwrite existing models with the same name to avoid `OverwriteModelError`
580
+ * @param {string} [collection] name (optional, inferred from model name)
581
+ * @param {object} [options]
582
+ * @param {boolean} [options.overwriteModels=false] If true, overwrite existing models with the same name to avoid `OverwriteModelError`
583
583
  * @return {Model} The model associated with `name`. Mongoose will create the model if it doesn't already exist.
584
584
  * @api public
585
585
  */
@@ -725,7 +725,7 @@ Mongoose.prototype._model = function _model(name, schema, collection, options) {
725
725
  * });
726
726
  *
727
727
  * @api public
728
- * @param {String|RegExp} name if string, the name of the model to remove. If regexp, removes all models whose name matches the regexp.
728
+ * @param {string|RegExp} name if string, the name of the model to remove. If regexp, removes all models whose name matches the regexp.
729
729
  * @return {Mongoose} this
730
730
  */
731
731
 
@@ -779,7 +779,7 @@ Mongoose.prototype._applyPlugins = function _applyPlugins(schema, options) {
779
779
  * Equivalent to calling `.plugin(fn)` on each Schema you create.
780
780
  *
781
781
  * @param {Function} fn plugin callback
782
- * @param {Object} [opts] optional options
782
+ * @param {object} [opts] optional options
783
783
  * @return {Mongoose} this
784
784
  * @see plugins https://mongoosejs.com/docs/plugins.html
785
785
  * @api public
@@ -860,7 +860,7 @@ Mongoose.prototype.connections;
860
860
  *
861
861
  * @memberOf Mongoose
862
862
  * @instance
863
- * @property {Number} nextConnectionId
863
+ * @property {number} nextConnectionId
864
864
  * @api private
865
865
  */
866
866
 
@@ -1102,7 +1102,7 @@ Mongoose.prototype.ObjectId = SchemaTypes.ObjectId;
1102
1102
  * mongoose.isValidObjectId({ test: 42 }); // false
1103
1103
  *
1104
1104
  * @method isValidObjectId
1105
- * @param {Any} v
1105
+ * @param {any} v
1106
1106
  * @returns {boolean} true if `v` is something Mongoose can coerce to an ObjectId
1107
1107
  * @api public
1108
1108
  */
@@ -1134,7 +1134,7 @@ Mongoose.prototype.isValidObjectId = function isValidObjectId(v) {
1134
1134
  * mongoose.isObjectIdOrHexString({ test: 42 }); // false
1135
1135
  *
1136
1136
  * @method isObjectIdOrHexString
1137
- * @param {Any} v
1137
+ * @param {any} v
1138
1138
  * @returns {boolean} true if `v` is an ObjectId instance _or_ a 24 char hex string
1139
1139
  * @api public
1140
1140
  */
@@ -1147,8 +1147,8 @@ Mongoose.prototype.isObjectIdOrHexString = function isObjectIdOrHexString(v) {
1147
1147
  *
1148
1148
  * Syncs all the indexes for the models registered with this connection.
1149
1149
  *
1150
- * @param {Object} options
1151
- * @param {Boolean} options.continueOnError `false` by default. If set to `true`, mongoose will not throw an error if one model syncing failed, and will return an object where the keys are the names of the models, and the values are the results/errors for each model.
1150
+ * @param {object} options
1151
+ * @param {boolean} options.continueOnError `false` by default. If set to `true`, mongoose will not throw an error if one model syncing failed, and will return an object where the keys are the names of the models, and the values are the results/errors for each model.
1152
1152
  * @return {Promise} Returns a Promise, when the Promise resolves the value is a list of the dropped indexes.
1153
1153
  */
1154
1154
  Mongoose.prototype.syncIndexes = function syncIndexes(options) {
@@ -1235,7 +1235,7 @@ Mongoose.prototype.MongooseError = MongooseError;
1235
1235
  * using a tool like [Sinon](https://www.npmjs.com/package/sinon) for testing.
1236
1236
  *
1237
1237
  * @method now
1238
- * @returns Date the current time
1238
+ * @returns {Date} the current time
1239
1239
  * @api public
1240
1240
  */
1241
1241
 
@@ -1245,9 +1245,9 @@ Mongoose.prototype.now = function now() { return new Date(); };
1245
1245
  * The Mongoose CastError constructor
1246
1246
  *
1247
1247
  * @method CastError
1248
- * @param {String} type The name of the type
1249
- * @param {Any} value The value that failed to cast
1250
- * @param {String} path The path `a.b.c` in the doc where this cast error occurred
1248
+ * @param {string} type The name of the type
1249
+ * @param {any} value The value that failed to cast
1250
+ * @param {string} path The path `a.b.c` in the doc where this cast error occurred
1251
1251
  * @param {Error} [reason] The original error that was thrown
1252
1252
  * @api public
1253
1253
  */
@@ -1283,8 +1283,8 @@ Mongoose.prototype.mquery = require('mquery');
1283
1283
  * ```
1284
1284
  *
1285
1285
  * @method sanitizeFilter
1286
- * @param {Object} filter
1287
- * @returns Object the sanitized object
1286
+ * @param {object} filter
1287
+ * @returns {object} the sanitized object
1288
1288
  * @api public
1289
1289
  */
1290
1290
 
@@ -1303,8 +1303,8 @@ Mongoose.prototype.sanitizeFilter = sanitizeFilter;
1303
1303
  * ```
1304
1304
  *
1305
1305
  * @method trusted
1306
- * @param {Object} obj
1307
- * @returns Object the passed in object
1306
+ * @param {object} obj
1307
+ * @returns {object} the passed in object
1308
1308
  * @api public
1309
1309
  */
1310
1310
 
@@ -1399,8 +1399,8 @@ Mongoose.prototype.overwriteMiddlewareArguments = Kareem.overwriteArguments;
1399
1399
  * await UserModel.findOne(mongoose.omitUndefined(filter));
1400
1400
  *
1401
1401
  * @method omitUndefined
1402
- * @param {Object} [val] the object to remove undefined keys from
1403
- * @returns {Object} the object passed in
1402
+ * @param {object} [val] the object to remove undefined keys from
1403
+ * @returns {object} the object passed in
1404
1404
  * @api public
1405
1405
  */
1406
1406
 
@@ -46,7 +46,7 @@ Object.defineProperty(SchemaArrayOptions.prototype, 'enum', opts);
46
46
  * @api public
47
47
  * @property of
48
48
  * @memberOf SchemaArrayOptions
49
- * @type {Function|String}
49
+ * @type {Function|string}
50
50
  * @instance
51
51
  */
52
52
 
@@ -65,7 +65,7 @@ Object.defineProperty(SchemaArrayOptions.prototype, 'of', opts);
65
65
  * @api public
66
66
  * @property castNonArrays
67
67
  * @memberOf SchemaArrayOptions
68
- * @type {Boolean}
68
+ * @type {boolean}
69
69
  * @instance
70
70
  */
71
71
 
@@ -25,7 +25,7 @@ const opts = require('./propertyOptions');
25
25
  * @api public
26
26
  * @property subtype
27
27
  * @memberOf SchemaBufferOptions
28
- * @type {Number}
28
+ * @type {number}
29
29
  * @instance
30
30
  */
31
31
 
@@ -26,7 +26,7 @@ const opts = require('./propertyOptions');
26
26
  * @api public
27
27
  * @property min
28
28
  * @memberOf SchemaNumberOptions
29
- * @type {Number}
29
+ * @type {number}
30
30
  * @instance
31
31
  */
32
32
 
@@ -39,7 +39,7 @@ Object.defineProperty(SchemaNumberOptions.prototype, 'min', opts);
39
39
  * @api public
40
40
  * @property max
41
41
  * @memberOf SchemaNumberOptions
42
- * @type {Number}
42
+ * @type {number}
43
43
  * @instance
44
44
  */
45
45
 
@@ -88,7 +88,7 @@ Object.defineProperty(SchemaNumberOptions.prototype, 'enum', opts);
88
88
  * @api public
89
89
  * @property populate
90
90
  * @memberOf SchemaNumberOptions
91
- * @type {Object}
91
+ * @type {object}
92
92
  * @instance
93
93
  */
94
94
 
@@ -25,7 +25,7 @@ const opts = require('./propertyOptions');
25
25
  * @api public
26
26
  * @property auto
27
27
  * @memberOf SchemaObjectIdOptions
28
- * @type {Boolean}
28
+ * @type {boolean}
29
29
  * @instance
30
30
  */
31
31
 
@@ -51,7 +51,7 @@ Object.defineProperty(SchemaObjectIdOptions.prototype, 'auto', opts);
51
51
  * @api public
52
52
  * @property populate
53
53
  * @memberOf SchemaObjectIdOptions
54
- * @type {Object}
54
+ * @type {object}
55
55
  * @instance
56
56
  */
57
57
 
@@ -51,7 +51,7 @@ Object.defineProperty(SchemaStringOptions.prototype, 'match', opts);
51
51
  * @api public
52
52
  * @property lowercase
53
53
  * @memberOf SchemaStringOptions
54
- * @type {Boolean}
54
+ * @type {boolean}
55
55
  * @instance
56
56
  */
57
57
 
@@ -64,7 +64,7 @@ Object.defineProperty(SchemaStringOptions.prototype, 'lowercase', opts);
64
64
  * @api public
65
65
  * @property trim
66
66
  * @memberOf SchemaStringOptions
67
- * @type {Boolean}
67
+ * @type {boolean}
68
68
  * @instance
69
69
  */
70
70
 
@@ -77,7 +77,7 @@ Object.defineProperty(SchemaStringOptions.prototype, 'trim', opts);
77
77
  * @api public
78
78
  * @property uppercase
79
79
  * @memberOf SchemaStringOptions
80
- * @type {Boolean}
80
+ * @type {boolean}
81
81
  * @instance
82
82
  */
83
83
 
@@ -94,7 +94,7 @@ Object.defineProperty(SchemaStringOptions.prototype, 'uppercase', opts);
94
94
  * @api public
95
95
  * @property minLength
96
96
  * @memberOf SchemaStringOptions
97
- * @type {Number}
97
+ * @type {number}
98
98
  * @instance
99
99
  */
100
100
 
@@ -112,7 +112,7 @@ Object.defineProperty(SchemaStringOptions.prototype, 'minlength', opts);
112
112
  * @api public
113
113
  * @property maxLength
114
114
  * @memberOf SchemaStringOptions
115
- * @type {Number}
115
+ * @type {number}
116
116
  * @instance
117
117
  */
118
118
 
@@ -125,7 +125,7 @@ Object.defineProperty(SchemaStringOptions.prototype, 'maxlength', opts);
125
125
  * @api public
126
126
  * @property populate
127
127
  * @memberOf SchemaStringOptions
128
- * @type {Object}
128
+ * @type {object}
129
129
  * @instance
130
130
  */
131
131
 
@@ -31,7 +31,7 @@ const opts = require('./propertyOptions');
31
31
  * @api public
32
32
  * @property type
33
33
  * @memberOf SchemaTypeOptions
34
- * @type {Function|String|Object}
34
+ * @type {Function|string|object}
35
35
  * @instance
36
36
  */
37
37
 
@@ -43,7 +43,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'type', opts);
43
43
  * @api public
44
44
  * @property validate
45
45
  * @memberOf SchemaTypeOptions
46
- * @type {Function|Object}
46
+ * @type {Function|object}
47
47
  * @instance
48
48
  */
49
49
 
@@ -74,7 +74,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'validate', opts);
74
74
  * @api public
75
75
  * @property cast
76
76
  * @memberOf SchemaTypeOptions
77
- * @type {String}
77
+ * @type {string}
78
78
  * @instance
79
79
  */
80
80
 
@@ -88,7 +88,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'cast', opts);
88
88
  * @api public
89
89
  * @property required
90
90
  * @memberOf SchemaTypeOptions
91
- * @type {Function|Boolean}
91
+ * @type {Function|boolean}
92
92
  * @instance
93
93
  */
94
94
 
@@ -101,7 +101,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'required', opts);
101
101
  * @api public
102
102
  * @property default
103
103
  * @memberOf SchemaTypeOptions
104
- * @type {Function|Any}
104
+ * @type {Function|any}
105
105
  * @instance
106
106
  */
107
107
 
@@ -113,7 +113,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'default', opts);
113
113
  * @api public
114
114
  * @property ref
115
115
  * @memberOf SchemaTypeOptions
116
- * @type {Function|String}
116
+ * @type {Function|string}
117
117
  * @instance
118
118
  */
119
119
 
@@ -126,7 +126,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'ref', opts);
126
126
  * @api public
127
127
  * @property ref
128
128
  * @memberOf SchemaTypeOptions
129
- * @type {Function|String}
129
+ * @type {Function|string}
130
130
  * @instance
131
131
  */
132
132
 
@@ -139,7 +139,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'refPath', opts);
139
139
  * @api public
140
140
  * @property select
141
141
  * @memberOf SchemaTypeOptions
142
- * @type {Boolean|Number}
142
+ * @type {boolean|number}
143
143
  * @instance
144
144
  */
145
145
 
@@ -152,7 +152,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'select', opts);
152
152
  * @api public
153
153
  * @property index
154
154
  * @memberOf SchemaTypeOptions
155
- * @type {Boolean|Number|Object}
155
+ * @type {boolean|number|object}
156
156
  * @instance
157
157
  */
158
158
 
@@ -166,7 +166,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'index', opts);
166
166
  * @api public
167
167
  * @property unique
168
168
  * @memberOf SchemaTypeOptions
169
- * @type {Boolean|Number}
169
+ * @type {boolean|number}
170
170
  * @instance
171
171
  */
172
172
 
@@ -180,7 +180,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'unique', opts);
180
180
  * @api public
181
181
  * @property immutable
182
182
  * @memberOf SchemaTypeOptions
183
- * @type {Function|Boolean}
183
+ * @type {Function|boolean}
184
184
  * @instance
185
185
  */
186
186
 
@@ -193,7 +193,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'immutable', opts);
193
193
  * @api public
194
194
  * @property sparse
195
195
  * @memberOf SchemaTypeOptions
196
- * @type {Boolean|Number}
196
+ * @type {boolean|number}
197
197
  * @instance
198
198
  */
199
199
 
@@ -206,7 +206,7 @@ Object.defineProperty(SchemaTypeOptions.prototype, 'sparse', opts);
206
206
  * @api public
207
207
  * @property text
208
208
  * @memberOf SchemaTypeOptions
209
- * @type {Boolean|Number|Object}
209
+ * @type {boolean|number|object}
210
210
  * @instance
211
211
  */
212
212
 
@@ -19,7 +19,7 @@ class VirtualOptions {
19
19
  * @api public
20
20
  * @property ref
21
21
  * @memberOf VirtualOptions
22
- * @type {String|Model|Function}
22
+ * @type {string|Model|Function}
23
23
  * @instance
24
24
  */
25
25
 
@@ -32,7 +32,7 @@ Object.defineProperty(VirtualOptions.prototype, 'ref', opts);
32
32
  * @api public
33
33
  * @property refPath
34
34
  * @memberOf VirtualOptions
35
- * @type {String|Function}
35
+ * @type {string|Function}
36
36
  * @instance
37
37
  */
38
38
 
@@ -45,7 +45,7 @@ Object.defineProperty(VirtualOptions.prototype, 'refPath', opts);
45
45
  * @api public
46
46
  * @property localField
47
47
  * @memberOf VirtualOptions
48
- * @type {String|Function}
48
+ * @type {string|Function}
49
49
  * @instance
50
50
  */
51
51
 
@@ -58,7 +58,7 @@ Object.defineProperty(VirtualOptions.prototype, 'localField', opts);
58
58
  * @api public
59
59
  * @property foreignField
60
60
  * @memberOf VirtualOptions
61
- * @type {String|Function}
61
+ * @type {string|Function}
62
62
  * @instance
63
63
  */
64
64
 
@@ -71,7 +71,7 @@ Object.defineProperty(VirtualOptions.prototype, 'foreignField', opts);
71
71
  * @api public
72
72
  * @property justOne
73
73
  * @memberOf VirtualOptions
74
- * @type {Boolean}
74
+ * @type {boolean}
75
75
  * @instance
76
76
  */
77
77
 
@@ -86,7 +86,7 @@ Object.defineProperty(VirtualOptions.prototype, 'justOne', opts);
86
86
  * @api public
87
87
  * @property count
88
88
  * @memberOf VirtualOptions
89
- * @type {Boolean}
89
+ * @type {boolean}
90
90
  * @instance
91
91
  */
92
92
 
@@ -99,7 +99,7 @@ Object.defineProperty(VirtualOptions.prototype, 'count', opts);
99
99
  * @api public
100
100
  * @property match
101
101
  * @memberOf VirtualOptions
102
- * @type {Object|Function}
102
+ * @type {object|Function}
103
103
  * @instance
104
104
  */
105
105
 
@@ -115,7 +115,7 @@ Object.defineProperty(VirtualOptions.prototype, 'match', opts);
115
115
  * @api public
116
116
  * @property options
117
117
  * @memberOf VirtualOptions
118
- * @type {Object}
118
+ * @type {object}
119
119
  * @instance
120
120
  */
121
121
 
@@ -127,7 +127,7 @@ Object.defineProperty(VirtualOptions.prototype, 'options', opts);
127
127
  * @api public
128
128
  * @property skip
129
129
  * @memberOf VirtualOptions
130
- * @type {Number}
130
+ * @type {number}
131
131
  * @instance
132
132
  */
133
133
 
@@ -139,7 +139,7 @@ Object.defineProperty(VirtualOptions.prototype, 'skip', opts);
139
139
  * @api public
140
140
  * @property limit
141
141
  * @memberOf VirtualOptions
142
- * @type {Number}
142
+ * @type {number}
143
143
  * @instance
144
144
  */
145
145
 
@@ -155,7 +155,7 @@ Object.defineProperty(VirtualOptions.prototype, 'limit', opts);
155
155
  * @api public
156
156
  * @property perDocumentLimit
157
157
  * @memberOf VirtualOptions
158
- * @type {Number}
158
+ * @type {number}
159
159
  * @instance
160
160
  */
161
161