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/connection.js CHANGED
@@ -158,7 +158,7 @@ Object.defineProperty(Connection.prototype, 'readyState', {
158
158
  *
159
159
  * conn.get('test'); // returns the 'test' value
160
160
  *
161
- * @param {String} key
161
+ * @param {string} key
162
162
  * @method get
163
163
  * @api public
164
164
  */
@@ -185,8 +185,8 @@ Connection.prototype.get = function getOption(key) {
185
185
  * conn.get('test'); // 'foo'
186
186
  * conn.options.test; // 'foo'
187
187
  *
188
- * @param {String} key
189
- * @param {Any} val
188
+ * @param {string} key
189
+ * @param {any} val
190
190
  * @method set
191
191
  * @api public
192
192
  */
@@ -414,7 +414,7 @@ Connection.prototype.config;
414
414
  *
415
415
  * @method createCollection
416
416
  * @param {string} collection The collection to create
417
- * @param {Object} [options] see [MongoDB driver docs](https://mongodb.github.io/node-mongodb-native/4.9/classes/Db.html#createCollection)
417
+ * @param {object} [options] see [MongoDB driver docs](https://mongodb.github.io/node-mongodb-native/4.9/classes/Db.html#createCollection)
418
418
  * @return {Promise}
419
419
  * @api public
420
420
  */
@@ -444,8 +444,8 @@ Connection.prototype.createCollection = async function createCollection(collecti
444
444
  *
445
445
  * @method bulkWrite
446
446
  * @param {Array} ops
447
- * @param {Object} [options]
448
- * @param {Boolean} [options.ordered] If false, perform unordered operations. If true, perform ordered operations.
447
+ * @param {object} [options]
448
+ * @param {boolean} [options.ordered] If false, perform unordered operations. If true, perform ordered operations.
449
449
  * @param {Session} [options.session] The session to use for the operation.
450
450
  * @return {Promise}
451
451
  * @see MongoDB https://www.mongodb.com/docs/manual/reference/command/bulkWrite/#mongodb-dbcommand-dbcmd.bulkWrite
@@ -606,7 +606,7 @@ Connection.prototype.bulkWrite = async function bulkWrite(ops, options) {
606
606
  * Calls `createCollection()` on a models in a series.
607
607
  *
608
608
  * @method createCollections
609
- * @param {Boolean} continueOnError When true, will continue to create collections and create a new error class for the collections that errored.
609
+ * @param {boolean} continueOnError When true, will continue to create collections and create a new error class for the collections that errored.
610
610
  * @returns {Promise}
611
611
  * @api public
612
612
  */
@@ -678,8 +678,8 @@ Connection.prototype.withSession = async function withSession(executor) {
678
678
  *
679
679
  *
680
680
  * @method startSession
681
- * @param {Object} [options] see the [mongodb driver options](https://mongodb.github.io/node-mongodb-native/4.9/classes/MongoClient.html#startSession)
682
- * @param {Boolean} [options.causalConsistency=true] set to false to disable causal consistency
681
+ * @param {object} [options] see the [mongodb driver options](https://mongodb.github.io/node-mongodb-native/4.9/classes/MongoClient.html#startSession)
682
+ * @param {boolean} [options.causalConsistency=true] set to false to disable causal consistency
683
683
  * @return {Promise<ClientSession>} promise that resolves to a MongoDB driver `ClientSession`
684
684
  * @api public
685
685
  */
@@ -723,7 +723,7 @@ Connection.prototype.startSession = async function startSession(options) {
723
723
  * @method transaction
724
724
  * @param {Function} fn Function to execute in a transaction
725
725
  * @param {mongodb.TransactionOptions} [options] Optional settings for the transaction
726
- * @return {Promise<Any>} promise that is fulfilled if Mongoose successfully committed the transaction, or rejects if the transaction was aborted or if Mongoose failed to commit the transaction. If fulfilled, the promise resolves to a MongoDB command result.
726
+ * @return {Promise<any>} promise that is fulfilled if Mongoose successfully committed the transaction, or rejects if the transaction was aborted or if Mongoose failed to commit the transaction. If fulfilled, the promise resolves to a MongoDB command result.
727
727
  * @api public
728
728
  */
729
729
 
@@ -824,8 +824,8 @@ Connection.prototype.dropCollection = async function dropCollection(collection)
824
824
  /**
825
825
  * Waits for connection to be established, so the connection has a `client`
826
826
  *
827
- * @param {Boolean} [noTimeout=false] if set, don't put a timeout on the operation. Used internally so `mongoose.model()` doesn't leave open handles.
828
- * @return Promise
827
+ * @param {boolean} [noTimeout=false] if set, don't put a timeout on the operation. Used internally so `mongoose.model()` doesn't leave open handles.
828
+ * @return {Promise}
829
829
  * @api private
830
830
  */
831
831
 
@@ -894,7 +894,7 @@ Connection.prototype._getBufferTimeoutMS = function _getBufferTimeoutMS() {
894
894
  * Returns an array of collection objects.
895
895
  *
896
896
  * @method listCollections
897
- * @return {Promise<Collection[]>}
897
+ * @return {Promise<Array<Collection>>}
898
898
  * @api public
899
899
  */
900
900
 
@@ -915,7 +915,7 @@ Connection.prototype.listCollections = async function listCollections() {
915
915
  * databases; // [{ name: 'mongoose_test', sizeOnDisk: 0, empty: false }]
916
916
  *
917
917
  * @method listCollections
918
- * @return {Promise<{ databases: Array<{ name: string }> }>}
918
+ * @return {Promise<Array<{ databases: { name: string } }>>}
919
919
  * @api public
920
920
  */
921
921
 
@@ -1024,22 +1024,22 @@ Connection.prototype.onOpen = function() {
1024
1024
  /**
1025
1025
  * Opens the connection with a URI using `MongoClient.connect()`.
1026
1026
  *
1027
- * @param {String} uri The URI to connect with.
1028
- * @param {Object} [options] Passed on to [`MongoClient.connect`](https://mongodb.github.io/node-mongodb-native/4.9/classes/MongoClient.html#connect-1)
1029
- * @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.
1030
- * @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.
1031
- * @param {String} [options.dbName] The name of the database we want to use. If not provided, use database name from connection string.
1032
- * @param {String} [options.user] username for authentication, equivalent to `options.auth.username`. Maintained for backwards compatibility.
1033
- * @param {String} [options.pass] password for authentication, equivalent to `options.auth.password`. Maintained for backwards compatibility.
1034
- * @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).
1035
- * @param {Number} [options.minPoolSize=0] 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).
1036
- * @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).
1037
- * @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.
1038
- * @param {Boolean} [options.autoIndex=true] Mongoose-specific option. Set to false to disable automatic index creation for all models associated with this connection.
1027
+ * @param {string} uri The URI to connect with.
1028
+ * @param {object} [options] Passed on to [`MongoClient.connect`](https://mongodb.github.io/node-mongodb-native/4.9/classes/MongoClient.html#connect-1)
1029
+ * @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.
1030
+ * @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.
1031
+ * @param {string} [options.dbName] The name of the database we want to use. If not provided, use database name from connection string.
1032
+ * @param {string} [options.user] username for authentication, equivalent to `options.auth.username`. Maintained for backwards compatibility.
1033
+ * @param {string} [options.pass] password for authentication, equivalent to `options.auth.password`. Maintained for backwards compatibility.
1034
+ * @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).
1035
+ * @param {number} [options.minPoolSize=0] 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).
1036
+ * @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).
1037
+ * @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.
1038
+ * @param {boolean} [options.autoIndex=true] Mongoose-specific option. Set to false to disable automatic index creation for all models associated with this connection.
1039
1039
  * @param {Class} [options.promiseLibrary] Sets the [underlying driver's promise library](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/MongoClientOptions.html#promiseLibrary).
1040
- * @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.
1041
- * @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.
1042
- * @param {Boolean} [options.autoCreate=false] Set to `true` to make Mongoose automatically call `createCollection()` on every model created on this connection.
1040
+ * @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.
1041
+ * @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.
1042
+ * @param {boolean} [options.autoCreate=false] Set to `true` to make Mongoose automatically call `createCollection()` on every model created on this connection.
1043
1043
  * @returns {Promise<Connection>}
1044
1044
  * @api public
1045
1045
  */
@@ -1106,7 +1106,7 @@ Connection.prototype.openUri = async function openUri(uri, options) {
1106
1106
  /**
1107
1107
  * Listen to events in the Connection
1108
1108
  *
1109
- * @param {String} event The event to listen on
1109
+ * @param {string} event The event to listen on
1110
1110
  * @param {Function} callback
1111
1111
  * @see Connection#readyState https://mongoosejs.com/docs/api/connection.html#Connection.prototype.readyState
1112
1112
  *
@@ -1128,7 +1128,7 @@ Connection.prototype.on = function on(event, callback) {
1128
1128
  /**
1129
1129
  * Listen to a event once in the Connection
1130
1130
  *
1131
- * @param {String} event The event to listen on
1131
+ * @param {string} event The event to listen on
1132
1132
  * @param {Function} callback
1133
1133
  * @see Connection#readyState https://mongoosejs.com/docs/api/connection.html#Connection.prototype.readyState
1134
1134
  *
@@ -1178,7 +1178,7 @@ function _handleConnectionErrors(err) {
1178
1178
  * but also removes the connection from Mongoose's `connections` list and prevents the
1179
1179
  * connection from ever being re-opened.
1180
1180
  *
1181
- * @param {Boolean} [force]
1181
+ * @param {boolean} [force]
1182
1182
  * @returns {Promise}
1183
1183
  */
1184
1184
 
@@ -1199,7 +1199,7 @@ Connection.prototype.destroy = async function destroy(force) {
1199
1199
  /**
1200
1200
  * Closes the connection
1201
1201
  *
1202
- * @param {Boolean} [force] optional
1202
+ * @param {boolean} [force] optional
1203
1203
  * @return {Promise}
1204
1204
  * @api public
1205
1205
  */
@@ -1232,8 +1232,8 @@ Connection.prototype.close = async function close(force) {
1232
1232
  /**
1233
1233
  * Handles closing the connection
1234
1234
  *
1235
- * @param {Boolean} force
1236
- * @param {Boolean} destroy
1235
+ * @param {boolean} force
1236
+ * @param {boolean} destroy
1237
1237
  * @returns {Connection} this
1238
1238
  * @api private
1239
1239
  */
@@ -1347,8 +1347,8 @@ Connection.prototype.onClose = function onClose(force) {
1347
1347
  * Using a Collection bypasses Mongoose middleware, validation, and casting,
1348
1348
  * letting you use [MongoDB Node.js driver](https://mongodb.github.io/node-mongodb-native/) functionality directly.
1349
1349
  *
1350
- * @param {String} name of the collection
1351
- * @param {Object} [options] optional collection options
1350
+ * @param {string} name of the collection
1351
+ * @param {object} [options] optional collection options
1352
1352
  * @return {Collection} collection instance
1353
1353
  * @api public
1354
1354
  */
@@ -1382,7 +1382,7 @@ Connection.prototype.collection = function(name, options) {
1382
1382
  * db.model('Test', new Schema({})); // Prints "Applied"
1383
1383
  *
1384
1384
  * @param {Function} fn plugin callback
1385
- * @param {Object} [opts] optional options
1385
+ * @param {object} [opts] optional options
1386
1386
  * @return {Connection} this
1387
1387
  * @see plugins https://mongoosejs.com/docs/plugins.html
1388
1388
  * @api public
@@ -1417,11 +1417,11 @@ Connection.prototype.plugin = function(fn, opts) {
1417
1417
  * const collectionName = 'actor'
1418
1418
  * const M = conn.model('Actor', schema, collectionName)
1419
1419
  *
1420
- * @param {String|Function} name the model name or class extending Model
1420
+ * @param {string|Function} name the model name or class extending Model
1421
1421
  * @param {Schema} [schema] a schema. necessary when defining a model
1422
- * @param {String} [collection] name of mongodb collection (optional) if not given it will be induced from model name
1423
- * @param {Object} [options]
1424
- * @param {Boolean} [options.overwriteModels=false] If true, overwrite existing models with the same name to avoid `OverwriteModelError`
1422
+ * @param {string} [collection] name of mongodb collection (optional) if not given it will be induced from model name
1423
+ * @param {object} [options]
1424
+ * @param {boolean} [options.overwriteModels=false] If true, overwrite existing models with the same name to avoid `OverwriteModelError`
1425
1425
  * @see Mongoose#model https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.model()
1426
1426
  * @return {Model} The compiled model
1427
1427
  * @api public
@@ -1543,7 +1543,7 @@ Connection.prototype.model = function model(name, schema, collection, options) {
1543
1543
  * });
1544
1544
  *
1545
1545
  * @api public
1546
- * @param {String|RegExp} name if string, the name of the model to remove. If regexp, removes all models whose name matches the regexp.
1546
+ * @param {string|RegExp} name if string, the name of the model to remove. If regexp, removes all models whose name matches the regexp.
1547
1547
  * @return {Connection} this
1548
1548
  */
1549
1549
 
@@ -1599,7 +1599,7 @@ Connection.prototype.deleteModel = function deleteModel(name) {
1599
1599
  *
1600
1600
  * @api public
1601
1601
  * @param {Array} [pipeline]
1602
- * @param {Object} [options] passed without changes to [the MongoDB driver's `Db#watch()` function](https://mongodb.github.io/node-mongodb-native/4.9/classes/Db.html#watch)
1602
+ * @param {object} [options] passed without changes to [the MongoDB driver's `Db#watch()` function](https://mongodb.github.io/node-mongodb-native/4.9/classes/Db.html#watch)
1603
1603
  * @return {ChangeStream} mongoose-specific change stream wrapper, inherits from EventEmitter
1604
1604
  */
1605
1605
 
@@ -1649,7 +1649,7 @@ Connection.prototype.asPromise = async function asPromise() {
1649
1649
  /**
1650
1650
  * Returns an array of model names created on this connection.
1651
1651
  * @api public
1652
- * @return {String[]}
1652
+ * @return {Array<string>}
1653
1653
  */
1654
1654
 
1655
1655
  Connection.prototype.modelNames = function modelNames() {
@@ -1662,7 +1662,7 @@ Connection.prototype.modelNames = function modelNames() {
1662
1662
  * password is not required.
1663
1663
  *
1664
1664
  * @api private
1665
- * @return {Boolean} true if the connection should be authenticated after it is opened, otherwise false.
1665
+ * @return {boolean} true if the connection should be authenticated after it is opened, otherwise false.
1666
1666
  */
1667
1667
  Connection.prototype.shouldAuthenticate = function shouldAuthenticate() {
1668
1668
  return this.user != null &&
@@ -1674,7 +1674,7 @@ Connection.prototype.shouldAuthenticate = function shouldAuthenticate() {
1674
1674
  * password to authenticate according to the auth objects passed into the openUri methods.
1675
1675
  *
1676
1676
  * @api private
1677
- * @return {Boolean} true if the authentication mechanism specified in the options object requires
1677
+ * @return {boolean} true if the authentication mechanism specified in the options object requires
1678
1678
  * a password, otherwise false.
1679
1679
  */
1680
1680
  Connection.prototype.authMechanismDoesNotRequirePassword = function authMechanismDoesNotRequirePassword() {
@@ -1690,9 +1690,9 @@ Connection.prototype.authMechanismDoesNotRequirePassword = function authMechanis
1690
1690
  * but in some authentication methods, a password is not required for authentication so only a username
1691
1691
  * is required.
1692
1692
  *
1693
- * @param {Object} [options] the options object passed into the openUri methods.
1693
+ * @param {object} [options] the options object passed into the openUri methods.
1694
1694
  * @api private
1695
- * @return {Boolean} true if the provided options object provides enough data to authenticate with,
1695
+ * @return {boolean} true if the provided options object provides enough data to authenticate with,
1696
1696
  * otherwise false.
1697
1697
  */
1698
1698
  Connection.prototype.optionsProvideAuthenticationData = function optionsProvideAuthenticationData(options) {
@@ -1754,9 +1754,9 @@ Connection.prototype.createClient = function createClient() {
1754
1754
  /**
1755
1755
  * Syncs all the indexes for the models registered with this connection.
1756
1756
  *
1757
- * @param {Object} [options]
1758
- * @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.
1759
- * @return {Promise<Object>} Returns a Promise, when the Promise resolves the value is a list of the dropped indexes.
1757
+ * @param {object} [options]
1758
+ * @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.
1759
+ * @return {Promise<object>} Returns a Promise, when the Promise resolves the value is a list of the dropped indexes.
1760
1760
  */
1761
1761
  Connection.prototype.syncIndexes = async function syncIndexes(options = {}) {
1762
1762
  const result = {};
@@ -1805,9 +1805,9 @@ Connection.prototype.syncIndexes = async function syncIndexes(options = {}) {
1805
1805
  *
1806
1806
  * @method useDb
1807
1807
  * @memberOf Connection
1808
- * @param {String} name The database name
1809
- * @param {Object} [options]
1810
- * @param {Boolean} [options.useCache=false] If true, cache results so calling `useDb()` multiple times with the same name only creates 1 connection object.
1808
+ * @param {string} name The database name
1809
+ * @param {object} [options]
1810
+ * @param {boolean} [options.useCache=false] If true, cache results so calling `useDb()` multiple times with the same name only creates 1 connection object.
1811
1811
  * @return {Connection} New Connection Object
1812
1812
  * @api public
1813
1813
  */
@@ -1818,8 +1818,8 @@ Connection.prototype.syncIndexes = async function syncIndexes(options = {}) {
1818
1818
  * @method aggregate
1819
1819
  * @memberOf Connection
1820
1820
  * @param {Array} pipeline
1821
- * @param {Object} [options]
1822
- * @param {Boolean} [options.cursor=false] If true, make the Aggregate resolve to a Mongoose AggregationCursor rather than an array
1821
+ * @param {object} [options]
1822
+ * @param {boolean} [options.cursor=false] If true, make the Aggregate resolve to a Mongoose AggregationCursor rather than an array
1823
1823
  * @return {Aggregate} Aggregation wrapper
1824
1824
  * @api public
1825
1825
  */
@@ -1842,7 +1842,7 @@ Connection.prototype.syncIndexes = async function syncIndexes(options = {}) {
1842
1842
  *
1843
1843
  * @method removeDb
1844
1844
  * @memberOf Connection
1845
- * @param {String} name The database name
1845
+ * @param {string} name The database name
1846
1846
  * @return {Connection} this
1847
1847
  * @api public
1848
1848
  */
@@ -293,10 +293,10 @@ AggregationCursor.prototype.next = async function next() {
293
293
  * Returns a promise that resolves when done.
294
294
  *
295
295
  * @param {Function} fn
296
- * @param {Object} [options]
297
- * @param {Number} [options.parallel] the number of promises to execute in parallel. Defaults to 1.
298
- * @param {Number} [options.batchSize=null] if set, Mongoose will call `fn` with an array of at most `batchSize` documents, instead of a single document
299
- * @param {Boolean} [options.continueOnError=false] if true, `eachAsync()` iterates through all docs even if `fn` throws an error. If false, `eachAsync()` throws an error immediately if the given function `fn()` throws an error.
296
+ * @param {object} [options]
297
+ * @param {number} [options.parallel] the number of promises to execute in parallel. Defaults to 1.
298
+ * @param {number} [options.batchSize=null] if set, Mongoose will call `fn` with an array of at most `batchSize` documents, instead of a single document
299
+ * @param {boolean} [options.continueOnError=false] if true, `eachAsync()` iterates through all docs even if `fn` throws an error. If false, `eachAsync()` throws an error immediately if the given function `fn()` throws an error.
300
300
  * @return {Promise}
301
301
  * @api public
302
302
  * @method eachAsync
@@ -390,7 +390,7 @@ function _transformForAsyncIterator(doc) {
390
390
  * Useful for setting the `noCursorTimeout` and `tailable` flags.
391
391
  *
392
392
  * @param {'tailable'|'oplogReplay'|'noCursorTimeout'|'awaitData'|'partial'} flag
393
- * @param {Boolean} value
393
+ * @param {boolean} value
394
394
  * @return {AggregationCursor} this
395
395
  * @api public
396
396
  * @method addCursorFlag
@@ -420,7 +420,7 @@ function _waitForCursor(ctx, cb) {
420
420
  /**
421
421
  * Get the next doc from the underlying cursor and mongooseify it
422
422
  * (populate, etc.)
423
- * @param {Any} ctx
423
+ * @param {any} ctx
424
424
  * @param {Function} cb
425
425
  * @api private
426
426
  */
@@ -26,7 +26,7 @@ const util = require('util');
26
26
  * Use [`Query#cursor()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.cursor()) instead.
27
27
  *
28
28
  * @param {Query} query
29
- * @param {Object} options query options passed to `.find()`
29
+ * @param {object} options query options passed to `.find()`
30
30
  * @inherits Readable https://nodejs.org/api/stream.html#class-streamreadable
31
31
  * @event `cursor`: Emitted when the cursor is created
32
32
  * @event `error`: Emitted when an error occurred
@@ -337,10 +337,10 @@ QueryCursor.prototype.next = async function next() {
337
337
  * })
338
338
  *
339
339
  * @param {Function} fn
340
- * @param {Object} [options]
341
- * @param {Number} [options.parallel] the number of promises to execute in parallel. Defaults to 1.
342
- * @param {Number} [options.batchSize] if set, will call `fn()` with arrays of documents with length at most `batchSize`
343
- * @param {Boolean} [options.continueOnError=false] if true, `eachAsync()` iterates through all docs even if `fn` throws an error. If false, `eachAsync()` throws an error immediately if the given function `fn()` throws an error.
340
+ * @param {object} [options]
341
+ * @param {number} [options.parallel] the number of promises to execute in parallel. Defaults to 1.
342
+ * @param {number} [options.batchSize] if set, will call `fn()` with arrays of documents with length at most `batchSize`
343
+ * @param {boolean} [options.continueOnError=false] if true, `eachAsync()` iterates through all docs even if `fn` throws an error. If false, `eachAsync()` throws an error immediately if the given function `fn()` throws an error.
344
344
  * @return {Promise}
345
345
  * @api public
346
346
  * @method eachAsync
@@ -372,7 +372,7 @@ QueryCursor.prototype.options;
372
372
  * Useful for setting the `noCursorTimeout` and `tailable` flags.
373
373
  *
374
374
  * @param {'tailable'|'oplogReplay'|'noCursorTimeout'|'awaitData'|'partial'} flag
375
- * @param {Boolean} value
375
+ * @param {boolean} value
376
376
  * @return {AggregationCursor} this
377
377
  * @api public
378
378
  * @method addCursorFlag
@@ -426,7 +426,7 @@ if (Symbol.asyncIterator != null) {
426
426
  /**
427
427
  * Get the next doc from the underlying cursor and mongooseify it
428
428
  * (populate, etc.)
429
- * @param {Any} ctx
429
+ * @param {any} ctx
430
430
  * @param {Function} cb
431
431
  * @api private
432
432
  */