mongoose 9.2.3 → 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 +7 -4
  117. package/types/schemaoptions.d.ts +1 -1
  118. package/types/virtuals.d.ts +10 -10
package/lib/schemaType.js CHANGED
@@ -33,9 +33,9 @@ const setOptionsForDefaults = { _skipMarkModified: true };
33
33
  * const schema = new Schema({ name: String });
34
34
  * schema.path('name') instanceof SchemaType; // true
35
35
  *
36
- * @param {String} path
36
+ * @param {string} path
37
37
  * @param {SchemaTypeOptions} [options] See [SchemaTypeOptions docs](https://mongoosejs.com/docs/api/schematypeoptions.html)
38
- * @param {String} [instance]
38
+ * @param {string} [instance]
39
39
  * @param {Schema} [parentSchema]
40
40
  * @api public
41
41
  */
@@ -215,9 +215,9 @@ SchemaType.prototype.validators;
215
215
  SchemaType.prototype.isRequired;
216
216
 
217
217
  /**
218
- * Split the current dottet path into segments
218
+ * Split the current dotted path into segments
219
219
  *
220
- * @return {String[]|undefined}
220
+ * @return {string[]|undefined}
221
221
  * @api private
222
222
  */
223
223
 
@@ -310,9 +310,9 @@ SchemaType.prototype.castFunction = function castFunction(caster, message) {
310
310
  /**
311
311
  * The function that Mongoose calls to cast arbitrary values to this SchemaType.
312
312
  *
313
- * @param {Object} value value to cast
313
+ * @param {object} value value to cast
314
314
  * @param {Document} doc document that triggers the casting
315
- * @param {Boolean} init
315
+ * @param {boolean} init
316
316
  * @api public
317
317
  */
318
318
 
@@ -328,8 +328,8 @@ SchemaType.prototype.cast = function cast() {
328
328
  * // Make all strings be trimmed by default
329
329
  * mongoose.SchemaTypes.String.set('trim', true);
330
330
  *
331
- * @param {String} option The name of the option you'd like to set (e.g. trim, lowercase, etc...)
332
- * @param {Any} value The value of the option you'd like to set.
331
+ * @param {string} option The name of the option you'd like to set (e.g. trim, lowercase, etc...)
332
+ * @param {any} value The value of the option you'd like to set.
333
333
  * @return {void}
334
334
  * @static
335
335
  * @memberOf SchemaType
@@ -404,7 +404,7 @@ SchemaType.get = function(getter) {
404
404
  * console.log(m2.mixed); // { added: 1 }
405
405
  *
406
406
  * @param {Function|any} val The default value to set
407
- * @return {Any|undefined} Returns the set default value.
407
+ * @return {any|undefined} Returns the set default value.
408
408
  * @api public
409
409
  */
410
410
 
@@ -443,7 +443,7 @@ SchemaType.prototype.default = function(val) {
443
443
  * s.path('my.date').index({ expires: 60 });
444
444
  * s.path('my.path').index({ unique: true, sparse: true });
445
445
  *
446
- * @param {Object|Boolean|String|Number} options
446
+ * @param {object|boolean|string|number} options
447
447
  * @return {SchemaType} this
448
448
  * @api public
449
449
  */
@@ -480,8 +480,8 @@ SchemaType.prototype.index = function(options) {
480
480
  * Note that the above syntax does **not** work for `bulkWrite()` or `insertMany()`. `bulkWrite()` and `insertMany()`
481
481
  * will still throw MongoDB's default `E11000 duplicate key error` message.
482
482
  *
483
- * @param {Boolean} value
484
- * @param {String} [message]
483
+ * @param {boolean} value
484
+ * @param {string} [message]
485
485
  * @return {SchemaType} this
486
486
  * @api public
487
487
  */
@@ -520,7 +520,7 @@ SchemaType.prototype.unique = function unique(value, message) {
520
520
  * const s = new Schema({ name : { type: String, text : true } })
521
521
  * s.path('name').index({ text : true });
522
522
  *
523
- * @param {Boolean} bool
523
+ * @param {boolean} bool
524
524
  * @return {SchemaType} this
525
525
  * @api public
526
526
  */
@@ -557,7 +557,7 @@ SchemaType.prototype.text = function(bool) {
557
557
  * const s = new Schema({ name: { type: String, sparse: true } });
558
558
  * s.path('name').index({ sparse: true });
559
559
  *
560
- * @param {Boolean} bool
560
+ * @param {boolean} bool
561
561
  * @return {SchemaType} this
562
562
  * @api public
563
563
  */
@@ -622,7 +622,7 @@ SchemaType.prototype.sparse = function(bool) {
622
622
  * // the property is immutable.
623
623
  * Model.updateOne({}, { name: 'test2' }, { strict: false });
624
624
  *
625
- * @param {Boolean} bool
625
+ * @param {boolean} bool
626
626
  * @return {SchemaType} this
627
627
  * @see isNew https://mongoosejs.com/docs/api/document.html#Document.prototype.isNew()
628
628
  * @api public
@@ -847,8 +847,8 @@ SchemaType.prototype.get = function(fn) {
847
847
  * Adds multiple validators for this document path.
848
848
  * Calls `validate()` for every element in validators.
849
849
  *
850
- * @param {Array<RegExp|Function|Object>} validators
851
- * @returns this
850
+ * @param {(RegExp|Function|object)[]} validators
851
+ * @returns {SchemaType}
852
852
  */
853
853
 
854
854
  SchemaType.prototype.validateAll = function(validators) {
@@ -955,12 +955,12 @@ SchemaType.prototype.validateAll = function(validators) {
955
955
  * // registering an error listener on the Model lets us handle errors more locally
956
956
  * Product.on('error', handleError);
957
957
  *
958
- * @param {RegExp|Function|Object} obj validator function, or hash describing options
958
+ * @param {RegExp|Function|object} obj validator function, or hash describing options
959
959
  * @param {Function} [obj.validator] validator function. If the validator function returns `undefined` or a truthy value, validation succeeds. If it returns [falsy](https://masteringjs.io/tutorials/fundamentals/falsy) (except `undefined`) or throws an error, validation fails.
960
- * @param {String|Function} [obj.message] optional error message. If function, should return the error message as a string
961
- * @param {Boolean} [obj.propsParameter=false] If true, Mongoose will pass the validator properties object (with the `validator` function, `message`, etc.) as the 2nd arg to the validator function. This is disabled by default because many validators [rely on positional args](https://github.com/chriso/validator.js#validators), so turning this on may cause unpredictable behavior in external validators.
962
- * @param {String|Function} [errorMsg] optional error message. If function, should return the error message as a string
963
- * @param {String} [type] optional validator type
960
+ * @param {string|Function} [obj.message] optional error message. If function, should return the error message as a string
961
+ * @param {boolean} [obj.propsParameter=false] If true, Mongoose will pass the validator properties object (with the `validator` function, `message`, etc.) as the 2nd arg to the validator function. This is disabled by default because many validators [rely on positional args](https://github.com/chriso/validator.js#validators), so turning this on may cause unpredictable behavior in external validators.
962
+ * @param {string|Function} [errorMsg] optional error message. If function, should return the error message as a string
963
+ * @param {string} [type] optional validator type
964
964
  * @return {SchemaType} this
965
965
  * @api public
966
966
  */
@@ -1063,10 +1063,10 @@ SchemaType.prototype.validate = function(obj, message, type) {
1063
1063
  * the value is not null nor undefined). However, most built-in mongoose schema
1064
1064
  * types override the default `checkRequired` function:
1065
1065
  *
1066
- * @param {Boolean|Function|Object} required enable/disable the validator, or function that returns required boolean, or options object
1067
- * @param {Boolean|Function} [options.isRequired] enable/disable the validator, or function that returns required boolean
1066
+ * @param {boolean|Function|object} required enable/disable the validator, or function that returns required boolean, or options object
1067
+ * @param {boolean|Function} [options.isRequired] enable/disable the validator, or function that returns required boolean
1068
1068
  * @param {Function} [options.ErrorConstructor] custom error constructor. The constructor receives 1 parameter, an object containing the validator properties.
1069
- * @param {String} [message] optional custom error message
1069
+ * @param {string} [message] optional custom error message
1070
1070
  * @return {SchemaType} this
1071
1071
  * @see Customized Error Messages https://mongoosejs.com/docs/api/error.html#Error.messages
1072
1072
  * @see SchemaArray#checkRequired https://mongoosejs.com/docs/api/schemaarray.html#SchemaArray.prototype.checkRequired()
@@ -1170,7 +1170,7 @@ SchemaType.prototype.required = function(required, message) {
1170
1170
  * user: { type: mongoose.ObjectId, ref: User }
1171
1171
  * });
1172
1172
  *
1173
- * @param {String|Model|Function} ref either a model name, a [Model](https://mongoosejs.com/docs/models.html), or a function that returns a model name or model.
1173
+ * @param {string|Model|Function} ref either a model name, a [Model](https://mongoosejs.com/docs/models.html), or a function that returns a model name or model.
1174
1174
  * @return {SchemaType} this
1175
1175
  * @api public
1176
1176
  */
@@ -1183,9 +1183,9 @@ SchemaType.prototype.ref = function(ref) {
1183
1183
  /**
1184
1184
  * Gets the default value
1185
1185
  *
1186
- * @param {Object} scope the scope which callback are executed
1187
- * @param {Boolean} init
1188
- * @return {Any} The Stored default value.
1186
+ * @param {object} scope the scope which callback are executed
1187
+ * @param {boolean} init
1188
+ * @return {any} The Stored default value.
1189
1189
  * @api private
1190
1190
  */
1191
1191
 
@@ -1229,11 +1229,11 @@ SchemaType.prototype.getDefault = function(scope, init, options) {
1229
1229
  /**
1230
1230
  * Applies setters without casting
1231
1231
  *
1232
- * @param {Any} value
1233
- * @param {Any} scope
1234
- * @param {Boolean} init
1235
- * @param {Any} priorVal
1236
- * @param {Object} [options]
1232
+ * @param {any} value
1233
+ * @param {any} scope
1234
+ * @param {boolean} init
1235
+ * @param {any} priorVal
1236
+ * @param {object} [options]
1237
1237
  * @instance
1238
1238
  * @api private
1239
1239
  */
@@ -1263,10 +1263,10 @@ SchemaType.prototype._castNullish = function _castNullish(v) {
1263
1263
  /**
1264
1264
  * Applies setters
1265
1265
  *
1266
- * @param {Object} value
1267
- * @param {Object} scope
1268
- * @param {Boolean} init
1269
- * @return {Any}
1266
+ * @param {any} value
1267
+ * @param {object} scope
1268
+ * @param {boolean} init
1269
+ * @return {any}
1270
1270
  * @api private
1271
1271
  */
1272
1272
 
@@ -1284,9 +1284,9 @@ SchemaType.prototype.applySetters = function(value, scope, init, priorVal, optio
1284
1284
  /**
1285
1285
  * Applies getters to a value
1286
1286
  *
1287
- * @param {Object} value
1288
- * @param {Object} scope
1289
- * @return {Any}
1287
+ * @param {object} value
1288
+ * @param {object} scope
1289
+ * @return {any}
1290
1290
  * @api private
1291
1291
  */
1292
1292
 
@@ -1318,7 +1318,7 @@ SchemaType.prototype.applyGetters = function(value, scope) {
1318
1318
  * // .. unless overridden;
1319
1319
  * T.find().select('-x').exec(callback);
1320
1320
  *
1321
- * @param {Boolean} val
1321
+ * @param {boolean} val
1322
1322
  * @return {SchemaType} this
1323
1323
  * @api public
1324
1324
  */
@@ -1331,11 +1331,11 @@ SchemaType.prototype.select = function select(val) {
1331
1331
  /**
1332
1332
  * Performs a validation of `value` using the validators declared for this SchemaType.
1333
1333
  *
1334
- * @param {Any} value
1335
- * @param {Object} scope
1336
- * @param {Object} [options]
1337
- * @param {String} [options.path]
1338
- * @return {Any} If no validators, returns the output from calling `fn`, otherwise no return
1334
+ * @param {any} value
1335
+ * @param {object} scope
1336
+ * @param {object} [options]
1337
+ * @param {string} [options.path]
1338
+ * @return {any} If no validators, returns the output from calling `fn`, otherwise no return
1339
1339
  * @api public
1340
1340
  */
1341
1341
 
@@ -1447,10 +1447,10 @@ function _validate(ok, validatorProperties) {
1447
1447
  *
1448
1448
  * This method ignores the asynchronous validators.
1449
1449
  *
1450
- * @param {Any} value
1451
- * @param {Object} scope
1452
- * @param {Object} [options]
1453
- * @param {Object} [options.path]
1450
+ * @param {any} value
1451
+ * @param {object} scope
1452
+ * @param {object} [options]
1453
+ * @param {string} [options.path]
1454
1454
  * @return {MongooseError|null}
1455
1455
  * @api private
1456
1456
  */
@@ -1539,10 +1539,10 @@ SchemaType.prototype.doValidateSync = function(value, scope, options) {
1539
1539
  * Determines if value is a valid Reference.
1540
1540
  *
1541
1541
  * @param {SchemaType} self
1542
- * @param {Object} value
1542
+ * @param {object} value
1543
1543
  * @param {Document} doc
1544
- * @param {Boolean} init
1545
- * @return {Boolean}
1544
+ * @param {boolean} init
1545
+ * @return {boolean}
1546
1546
  * @api private
1547
1547
  */
1548
1548
 
@@ -1684,10 +1684,10 @@ SchemaType.prototype.$conditionalHandlers = {
1684
1684
  /**
1685
1685
  * Cast the given value with the given optional query operator.
1686
1686
  *
1687
- * @param {String} [$conditional] query operator, like `$eq` or `$in`
1688
- * @param {Any} val
1687
+ * @param {string} [$conditional] query operator, like `$eq` or `$in`
1688
+ * @param {any} val
1689
1689
  * @param {Query} context
1690
- * @return {Any}
1690
+ * @return {any}
1691
1691
  * @api private
1692
1692
  */
1693
1693
 
@@ -1740,8 +1740,8 @@ SchemaType.checkRequired = function(fn) {
1740
1740
  /**
1741
1741
  * Default check for if this path satisfies the `required` validator.
1742
1742
  *
1743
- * @param {Any} val
1744
- * @return {Boolean} `true` when the value is not `null`, `false` otherwise
1743
+ * @param {any} val
1744
+ * @return {boolean} `true` when the value is not `null`, `false` otherwise
1745
1745
  * @api private
1746
1746
  */
1747
1747
 
@@ -1806,9 +1806,9 @@ SchemaType.prototype._duplicateKeyErrorMessage = null;
1806
1806
  /**
1807
1807
  * Returns this schema type's representation in a JSON schema.
1808
1808
  *
1809
- * @param [options]
1810
- * @param [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
1811
- * @returns {Object} JSON schema properties
1809
+ * @param {object} [options]
1810
+ * @param {boolean} [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
1811
+ * @returns {object} JSON schema properties
1812
1812
  */
1813
1813
 
1814
1814
  SchemaType.prototype.toJSONSchema = function toJSONSchema(_options) { // eslint-disable-line no-unused-vars
@@ -25,8 +25,7 @@ const StateMachine = module.exports = exports = function StateMachine() {
25
25
  * methods named after each state. These transition methods
26
26
  * place their path argument into the given state.
27
27
  *
28
- * @param {String} state
29
- * @param {String} [state]
28
+ * @param {...string} state one or more state names
30
29
  * @return {Function} subclass constructor
31
30
  * @api private
32
31
  */
@@ -126,7 +125,7 @@ StateMachine.prototype.getStatePaths = function getStatePaths(state) {
126
125
  * Checks to see if at least one path is in the states passed in via `arguments`
127
126
  * e.g., this.some('required', 'inited')
128
127
  *
129
- * @param {String} state that we want to check for.
128
+ * @param {string} state that we want to check for.
130
129
  * @api private
131
130
  */
132
131
 
@@ -145,7 +144,7 @@ StateMachine.prototype.some = function some() {
145
144
  * This function builds the functions that get assigned to `forEach` and `map`,
146
145
  * since both of those methods share a lot of the same logic.
147
146
  *
148
- * @param {String} iterMethod is either 'forEach' or 'map'
147
+ * @param {string} iterMethod is either 'forEach' or 'map'
149
148
  * @return {Function}
150
149
  * @api private
151
150
  */
@@ -180,8 +179,7 @@ StateMachine.prototype._iter = function _iter(iterMethod) {
180
179
  * this.forEach(state1, state2, fn); // iterates over all paths in state1 or state2
181
180
  * this.forEach(fn); // iterates over all paths in all states
182
181
  *
183
- * @param {String} [state]
184
- * @param {String} [state]
182
+ * @param {...string} [state] one or more state names to filter by
185
183
  * @param {Function} callback
186
184
  * @api private
187
185
  */
@@ -199,8 +197,7 @@ StateMachine.prototype.forEach = function forEach() {
199
197
  * this.forEach(state1, state2, fn); // iterates over all paths in state1 or state2
200
198
  * this.forEach(fn); // iterates over all paths in all states
201
199
  *
202
- * @param {String} [state]
203
- * @param {String} [state]
200
+ * @param {...string} [state] one or more state names to filter by
204
201
  * @param {Function} callback
205
202
  * @return {Array}
206
203
  * @api private
@@ -20,7 +20,7 @@ const arraySchemaSymbol = require('../../helpers/symbols').arraySchemaSymbol;
20
20
  * _Values always have to be passed to the constructor to initialize, otherwise `MongooseArray#push` will mark the array as modified._
21
21
  *
22
22
  * @param {Array} values
23
- * @param {String} path
23
+ * @param {string} path
24
24
  * @param {Document} doc parent document
25
25
  * @api private
26
26
  * @inherits Array https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
@@ -246,7 +246,7 @@ const methods = {
246
246
  * Casts a member based on this arrays schema.
247
247
  *
248
248
  * @param {any} value
249
- * @return value the casted value
249
+ * @return {any} the casted value
250
250
  * @method _cast
251
251
  * @api private
252
252
  * @memberOf MongooseArray
@@ -291,7 +291,7 @@ const methods = {
291
291
  * Internal helper for .map()
292
292
  *
293
293
  * @api private
294
- * @return {Number}
294
+ * @return {number}
295
295
  * @method _mapCast
296
296
  * @memberOf MongooseArray
297
297
  */
@@ -306,7 +306,7 @@ const methods = {
306
306
  * If it bubbles up from an embedded document change, then it takes the following arguments (otherwise, takes 0 arguments)
307
307
  *
308
308
  * @param {ArraySubdocument} subdoc the embedded doc that invoked this method on the Array
309
- * @param {String} embeddedPath the path which changed in the subdoc
309
+ * @param {string} embeddedPath the path which changed in the subdoc
310
310
  * @method _markModified
311
311
  * @api private
312
312
  * @memberOf MongooseArray
@@ -500,7 +500,7 @@ const methods = {
500
500
  * Returns the number of pending atomic operations to send to the db for this array.
501
501
  *
502
502
  * @api private
503
- * @return {Number}
503
+ * @return {number}
504
504
  * @method hasAtomics
505
505
  * @memberOf MongooseArray
506
506
  */
@@ -516,9 +516,9 @@ const methods = {
516
516
  /**
517
517
  * Return whether or not the `obj` is included in the array.
518
518
  *
519
- * @param {Object} obj the item to check
520
- * @param {Number} fromIndex
521
- * @return {Boolean}
519
+ * @param {object} obj the item to check
520
+ * @param {number} fromIndex
521
+ * @return {boolean}
522
522
  * @api public
523
523
  * @method includes
524
524
  * @memberOf MongooseArray
@@ -532,9 +532,9 @@ const methods = {
532
532
  /**
533
533
  * Return the index of `obj` or `-1` if not found.
534
534
  *
535
- * @param {Object} obj the item to look for
536
- * @param {Number} fromIndex
537
- * @return {Number}
535
+ * @param {object} obj the item to look for
536
+ * @param {number} fromIndex
537
+ * @return {number}
538
538
  * @api public
539
539
  * @method indexOf
540
540
  * @memberOf MongooseArray
@@ -707,7 +707,7 @@ const methods = {
707
707
  * });
708
708
  * doc.nums; // [1, 2, 3, 4, 5]
709
709
  *
710
- * @param {...Object} [args]
710
+ * @param {...object} [args]
711
711
  * @api public
712
712
  * @method push
713
713
  * @memberOf MongooseArray
@@ -916,7 +916,7 @@ const methods = {
916
916
  /**
917
917
  * Returns a native js Array.
918
918
  *
919
- * @param {Object} options
919
+ * @param {object} options
920
920
  * @return {Array}
921
921
  * @api public
922
922
  * @method toObject
@@ -13,11 +13,11 @@ const documentArrayParent = require('../helpers/symbols').documentArrayParent;
13
13
  /**
14
14
  * A constructor.
15
15
  *
16
- * @param {Object} obj js object returned from the db
16
+ * @param {object} obj js object returned from the db
17
17
  * @param {MongooseDocumentArray} parentArr the parent array of this document
18
- * @param {Boolean} skipId
19
- * @param {Object} fields
20
- * @param {Number} index
18
+ * @param {boolean} skipId
19
+ * @param {object} fields
20
+ * @param {number} index
21
21
  * @inherits Document
22
22
  * @api private
23
23
  */
@@ -107,9 +107,9 @@ ArraySubdocument.prototype.$__removeFromParent = function() {
107
107
  /**
108
108
  * Returns the full path to this document. If optional `path` is passed, it is appended to the full path.
109
109
  *
110
- * @param {String} [path]
111
- * @param {Boolean} [skipIndex] Skip adding the array index. For example `arr.foo` instead of `arr.0.foo`.
112
- * @return {String}
110
+ * @param {string} [path]
111
+ * @param {boolean} [skipIndex] Skip adding the array index. For example `arr.foo` instead of `arr.0.foo`.
112
+ * @return {string}
113
113
  * @api private
114
114
  * @method $__fullPath
115
115
  * @memberOf ArraySubdocument
@@ -194,7 +194,7 @@ ArraySubdocument.prototype.$__setParent = function $__setParent(parent) {
194
194
  *
195
195
  * @api public
196
196
  * @method parentArray
197
- * @returns DocumentArray
197
+ * @returns {DocumentArray}
198
198
  */
199
199
 
200
200
  ArraySubdocument.prototype.parentArray = function() {
@@ -14,8 +14,8 @@ const utils = require('../utils');
14
14
  * Values always have to be passed to the constructor to initialize.
15
15
  *
16
16
  * @param {Buffer} value
17
- * @param {String} encode
18
- * @param {Number} offset
17
+ * @param {string} encode
18
+ * @param {number} offset
19
19
  * @api private
20
20
  * @inherits Buffer https://nodejs.org/api/buffer.html
21
21
  * @see https://bit.ly/f6CnZU
@@ -121,7 +121,7 @@ MongooseBuffer.mixin = {
121
121
  *
122
122
  * `Buffer#copy` does not mark `target` as modified so you must copy from a `MongooseBuffer` for it to work as expected. This is a work around since `copy` modifies the target, not this.
123
123
  *
124
- * @return {Number} The number of bytes copied.
124
+ * @return {number} The number of bytes copied.
125
125
  * @param {Buffer} target
126
126
  * @method copy
127
127
  * @memberOf MongooseBuffer.mixin
@@ -228,7 +228,7 @@ MongooseBuffer.mixin.toUUID = function() {
228
228
  * Determines if this buffer is equals to `other` buffer
229
229
  *
230
230
  * @param {Buffer} other
231
- * @return {Boolean}
231
+ * @return {boolean}
232
232
  * @method equals
233
233
  * @memberOf MongooseBuffer
234
234
  */
@@ -19,7 +19,7 @@ const numberRE = /^\d+$/;
19
19
  * DocumentArray constructor
20
20
  *
21
21
  * @param {Array} values
22
- * @param {String} path the path to this array
22
+ * @param {string} path the path to this array
23
23
  * @param {Document} doc parent document
24
24
  * @api private
25
25
  * @return {MongooseDocumentArray}
@@ -119,7 +119,7 @@ const methods = {
119
119
  * const embeddedDoc = m.array.id(some_id);
120
120
  *
121
121
  * @return {EmbeddedDocument|null} the subdocument or null if not found.
122
- * @param {ObjectId|String|Number|Buffer} id
122
+ * @param {ObjectId|string|number|Buffer} id
123
123
  * @method id
124
124
  * @api public
125
125
  * @memberOf MongooseDocumentArray
@@ -185,7 +185,7 @@ const methods = {
185
185
  *
186
186
  * _Each sub-document is converted to a plain object by calling its `#toObject` method._
187
187
  *
188
- * @param {Object} [options] optional options to pass to each documents `toObject` method call during conversion
188
+ * @param {object} [options] optional options to pass to each documents `toObject` method call during conversion
189
189
  * @return {Array}
190
190
  * @method toObject
191
191
  * @api public
@@ -213,7 +213,7 @@ const methods = {
213
213
  /**
214
214
  * Wraps [`Array#push`](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/push) with proper change tracking.
215
215
  *
216
- * @param {...Object} [args]
216
+ * @param {...object} [args]
217
217
  * @api public
218
218
  * @method push
219
219
  * @memberOf MongooseDocumentArray
@@ -230,7 +230,7 @@ const methods = {
230
230
  /**
231
231
  * Pulls items from the array atomically.
232
232
  *
233
- * @param {...Object} [args]
233
+ * @param {...object} [args]
234
234
  * @api public
235
235
  * @method pull
236
236
  * @memberOf MongooseDocumentArray
@@ -287,7 +287,7 @@ const methods = {
287
287
  *
288
288
  * This is the same subdocument constructor used for casting.
289
289
  *
290
- * @param {Object} obj the value to cast to this arrays SubDocument schema
290
+ * @param {object} obj the value to cast to this arrays SubDocument schema
291
291
  * @method create
292
292
  * @api public
293
293
  * @memberOf MongooseDocumentArray
package/lib/types/map.js CHANGED
@@ -251,8 +251,8 @@ class MongooseMap extends Map {
251
251
  *
252
252
  * @api public
253
253
  * @method toJSON
254
- * @param {Object} [options]
255
- * @param {Boolean} [options.flattenMaps=false] set to `true` to convert the map to a POJO rather than a native JavaScript map
254
+ * @param {object} [options]
255
+ * @param {boolean} [options.flattenMaps=false] set to `true` to convert the map to a POJO rather than a native JavaScript map
256
256
  * @memberOf Map
257
257
  */
258
258
 
@@ -345,7 +345,7 @@ Object.defineProperty(MongooseMap.prototype, '$__deferredCalls', {
345
345
  /**
346
346
  * Since maps are stored as objects under the hood, keys must be strings
347
347
  * and can't contain any invalid characters
348
- * @param {String} key
348
+ * @param {string} key
349
349
  * @api private
350
350
  */
351
351
 
@@ -60,11 +60,11 @@ Subdocument.prototype.toBSON = function() {
60
60
  *
61
61
  * _This is a no-op. Does not actually save the doc to the db._
62
62
  *
63
- * @param {Object} [options]
64
- * @param {Boolean} [options.suppressWarning=false] If `true`, suppress the warning about calling `save()` on a subdoc.
65
- * @param {Boolean|Object} [options.middleware=true] set to `false` to skip all user-defined middleware
66
- * @param {Boolean} [options.middleware.pre=true] set to `false` to skip only pre hooks
67
- * @param {Boolean} [options.middleware.post=true] set to `false` to skip only post hooks
63
+ * @param {object} [options]
64
+ * @param {boolean} [options.suppressWarning=false] If `true`, suppress the warning about calling `save()` on a subdoc.
65
+ * @param {boolean|object} [options.middleware=true] set to `false` to skip all user-defined middleware
66
+ * @param {boolean} [options.middleware.pre=true] set to `false` to skip only pre hooks
67
+ * @param {boolean} [options.middleware.post=true] set to `false` to skip only post hooks
68
68
  * @return {Promise} resolved Promise
69
69
  * @api private
70
70
  */
@@ -85,11 +85,11 @@ Subdocument.prototype.save = async function save(options) {
85
85
  /**
86
86
  * Given a path relative to this document, return the path relative
87
87
  * to the top-level document.
88
- * @param {String} path
88
+ * @param {string} path
89
89
  * @method $__fullPath
90
90
  * @memberOf Subdocument
91
91
  * @instance
92
- * @returns {String}
92
+ * @returns {string}
93
93
  * @api private
94
94
  */
95
95
 
@@ -106,8 +106,8 @@ Subdocument.prototype.$__fullPath = function(path) {
106
106
  /**
107
107
  * Given a path relative to this document, return the path relative
108
108
  * to the parent document.
109
- * @param {String} p
110
- * @returns {String}
109
+ * @param {string} p
110
+ * @returns {string}
111
111
  * @method $__pathRelativeToParent
112
112
  * @memberOf Subdocument
113
113
  * @instance
@@ -203,7 +203,7 @@ Subdocument.prototype.isModified = function(paths, options, modifiedPaths) {
203
203
  /**
204
204
  * Marks a path as valid, removing existing validation errors.
205
205
  *
206
- * @param {String} path the field to mark as valid
206
+ * @param {string} path the field to mark as valid
207
207
  * @api private
208
208
  * @method $markValid
209
209
  * @memberOf Subdocument
@@ -360,7 +360,7 @@ Subdocument.prototype.$__removeFromParent = function() {
360
360
  /**
361
361
  * Null-out this subdoc
362
362
  *
363
- * @param {Object} [options]
363
+ * @param {object} [options]
364
364
  */
365
365
 
366
366
  Subdocument.prototype.deleteOne = function deleteOne(options) {