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/schema.js CHANGED
@@ -98,8 +98,8 @@ const numberRE = /^\d+$/;
98
98
  *
99
99
  * _When nesting schemas, (`children` in the example above), always declare the child schema first before passing it into its parent._
100
100
  *
101
- * @param {Object|Schema|Array} [definition] Can be one of: object describing schema paths, or schema to copy, or array of objects and schemas
102
- * @param {Object} [options]
101
+ * @param {object|Schema|Array} [definition] Can be one of: object describing schema paths, or schema to copy, or array of objects and schemas
102
+ * @param {object} [options]
103
103
  * @inherits NodeJS EventEmitter https://nodejs.org/api/events.html#class-eventemitter
104
104
  * @event `init`: Emitted after the schema is compiled into a `Model`.
105
105
  * @api public
@@ -385,8 +385,8 @@ Schema.prototype.tree;
385
385
  * // Equivalent:
386
386
  * const schema2 = new Schema({ name: String }, { toObject: { virtuals: true } });
387
387
  *
388
- * @param {Object} definition
389
- * @param {Object} [options]
388
+ * @param {object} definition
389
+ * @param {object} [options]
390
390
  * @return {Schema} the new schema
391
391
  * @api public
392
392
  * @memberOf Schema
@@ -510,8 +510,8 @@ Schema.prototype._clone = function _clone(Constructor) {
510
510
  * newSchema.path('name'); // SchemaString { ... }
511
511
  * newSchema.path('age'); // undefined
512
512
  *
513
- * @param {String[]} paths List of Paths to pick for the new Schema
514
- * @param {Object} [options] Options to pass to the new Schema Constructor (same as `new Schema(.., Options)`). Defaults to `this.options` if not set.
513
+ * @param {string[]} paths List of Paths to pick for the new Schema
514
+ * @param {object} [options] Options to pass to the new Schema Constructor (same as `new Schema(.., Options)`). Defaults to `this.options` if not set.
515
515
  * @return {Schema}
516
516
  * @api public
517
517
  */
@@ -565,8 +565,8 @@ Schema.prototype.pick = function(paths, options) {
565
565
  * newSchema.path('name'); // SchemaString { ... }
566
566
  * newSchema.path('age'); // undefined
567
567
  *
568
- * @param {String[]} paths List of Paths to omit for the new Schema
569
- * @param {Object} [options] Options to pass to the new Schema Constructor (same as `new Schema(.., Options)`). Defaults to `this.options` if not set.
568
+ * @param {string[]} paths List of Paths to omit for the new Schema
569
+ * @param {object} [options] Options to pass to the new Schema Constructor (same as `new Schema(.., Options)`). Defaults to `this.options` if not set.
570
570
  * @return {Schema}
571
571
  * @api public
572
572
  */
@@ -596,8 +596,8 @@ Schema.prototype.omit = function(paths, options) {
596
596
  /**
597
597
  * Returns default options for this schema, merged with `options`.
598
598
  *
599
- * @param {Object} [options] Options to overwrite the default options
600
- * @return {Object} The merged options of `options` and the default options
599
+ * @param {object} [options] Options to overwrite the default options
600
+ * @return {object} The merged options of `options` and the default options
601
601
  * @api private
602
602
  */
603
603
 
@@ -672,14 +672,14 @@ Schema.prototype.defaultOptions = function(options) {
672
672
  * doc.element; // '#hero'
673
673
  * doc instanceof ClickedModel; // true
674
674
  *
675
- * @param {String} name the name of the discriminator
675
+ * @param {string} name the name of the discriminator
676
676
  * @param {Schema} schema the discriminated Schema
677
- * @param {Object} [options] discriminator options
678
- * @param {String} [options.value] the string stored in the `discriminatorKey` property. If not specified, Mongoose uses the `name` parameter.
679
- * @param {Boolean} [options.clone=true] By default, `discriminator()` clones the given `schema`. Set to `false` to skip cloning.
680
- * @param {Boolean} [options.overwriteModels=false] by default, Mongoose does not allow you to define a discriminator with the same name as another discriminator. Set this to allow overwriting discriminators with the same name.
681
- * @param {Boolean} [options.mergeHooks=true] By default, Mongoose merges the base schema's hooks with the discriminator schema's hooks. Set this option to `false` to make Mongoose use the discriminator schema's hooks instead.
682
- * @param {Boolean} [options.mergePlugins=true] By default, Mongoose merges the base schema's plugins with the discriminator schema's plugins. Set this option to `false` to make Mongoose use the discriminator schema's plugins instead.
677
+ * @param {object} [options] discriminator options
678
+ * @param {string} [options.value] the string stored in the `discriminatorKey` property. If not specified, Mongoose uses the `name` parameter.
679
+ * @param {boolean} [options.clone=true] By default, `discriminator()` clones the given `schema`. Set to `false` to skip cloning.
680
+ * @param {boolean} [options.overwriteModels=false] by default, Mongoose does not allow you to define a discriminator with the same name as another discriminator. Set this to allow overwriting discriminators with the same name.
681
+ * @param {boolean} [options.mergeHooks=true] By default, Mongoose merges the base schema's hooks with the discriminator schema's hooks. Set this option to `false` to make Mongoose use the discriminator schema's hooks instead.
682
+ * @param {boolean} [options.mergePlugins=true] By default, Mongoose merges the base schema's plugins with the discriminator schema's plugins. Set this option to `false` to make Mongoose use the discriminator schema's plugins instead.
683
683
  * @return {Schema} the Schema instance
684
684
  * @api public
685
685
  */
@@ -768,8 +768,8 @@ Schema.prototype.encryptionType = function encryptionType(encryptionType) {
768
768
  * // getters, setters, indexes, methods, and statics.
769
769
  * TurboManSchema.add(ToySchema).add({ year: Number });
770
770
  *
771
- * @param {Object|Schema} obj plain object with paths to add, or another schema
772
- * @param {String} [prefix] path to prefix the newly added paths with
771
+ * @param {object|Schema} obj plain object with paths to add, or another schema
772
+ * @param {string} [prefix] path to prefix the newly added paths with
773
773
  * @return {Schema} the Schema instance
774
774
  * @api public
775
775
  */
@@ -1073,8 +1073,8 @@ Schema.prototype._buildSchemaMap = function() {
1073
1073
  * await turboMan.save(); // Saves { _id: ..., n: 'Turbo Man Action Figure' }
1074
1074
  *
1075
1075
  *
1076
- * @param {String} path real path to alias
1077
- * @param {String|String[]} alias the path(s) to use as an alias for `path`
1076
+ * @param {string} path real path to alias
1077
+ * @param {string|string[]} alias the path(s) to use as an alias for `path`
1078
1078
  * @return {Schema} the Schema instance
1079
1079
  * @api public
1080
1080
  */
@@ -1106,7 +1106,7 @@ Schema.prototype.alias = function alias(path, alias) {
1106
1106
  * // Remove index by name
1107
1107
  * ToySchema.removeIndex('my custom index name');
1108
1108
  *
1109
- * @param {Object|string} index name or index specification
1109
+ * @param {object|string} index name or index specification
1110
1110
  * @return {Schema} the Schema instance
1111
1111
  * @api public
1112
1112
  */
@@ -1173,9 +1173,9 @@ Schema.prototype.clearIndexes = function clearIndexes() {
1173
1173
  * const ToySchema = new Schema({ name: String, color: String, price: Number });
1174
1174
  * ToySchema.searchIndex({ name: 'test', definition: { mappings: { dynamic: true } } });
1175
1175
  *
1176
- * @param {Object} description index options, including `name` and `definition`
1177
- * @param {String} description.name
1178
- * @param {Object} description.definition
1176
+ * @param {object} description index options, including `name` and `definition`
1177
+ * @param {string} description.name
1178
+ * @param {object} description.definition
1179
1179
  * @return {Schema} the Schema instance
1180
1180
  * @api public
1181
1181
  */
@@ -1261,8 +1261,8 @@ reserved.collection = 1;
1261
1261
  * schema.path('name') // returns a SchemaType
1262
1262
  * schema.path('name', Number) // changes the schemaType of `name` to Number
1263
1263
  *
1264
- * @param {String} path The name of the Path to get / set
1265
- * @param {Object} [obj] The Type to set the path to, if provided the path will be SET, otherwise the path will be GET
1264
+ * @param {string} path The name of the Path to get / set
1265
+ * @param {object} [obj] The Type to set the path to, if provided the path will be SET, otherwise the path will be GET
1266
1266
  * @api public
1267
1267
  */
1268
1268
 
@@ -1571,9 +1571,9 @@ Object.defineProperty(Schema.prototype, 'base', {
1571
1571
  /**
1572
1572
  * Converts type arguments into Mongoose Types.
1573
1573
  *
1574
- * @param {String} path
1575
- * @param {Object} obj constructor
1576
- * @param {Object} options schema options
1574
+ * @param {string} path
1575
+ * @param {object} obj constructor
1576
+ * @param {object} options schema options
1577
1577
  * @api private
1578
1578
  */
1579
1579
 
@@ -1840,7 +1840,7 @@ Schema.prototype.eachPath = function(fn) {
1840
1840
  * s.requiredPaths(); // [ 'age', 'name' ]
1841
1841
  *
1842
1842
  * @api public
1843
- * @param {Boolean} invalidate Refresh the cache
1843
+ * @param {boolean} invalidate Refresh the cache
1844
1844
  * @return {Array}
1845
1845
  */
1846
1846
 
@@ -1892,8 +1892,8 @@ Schema.prototype.indexedPaths = function indexedPaths() {
1892
1892
  * s.pathType('foo'); // "virtual"
1893
1893
  * s.pathType('fail'); // "adhocOrUndefined"
1894
1894
  *
1895
- * @param {String} path
1896
- * @return {String}
1895
+ * @param {string} path
1896
+ * @return {string}
1897
1897
  * @api public
1898
1898
  */
1899
1899
 
@@ -1935,8 +1935,8 @@ Schema.prototype.pathType = function(path) {
1935
1935
  /**
1936
1936
  * Returns true iff this path is a child of a mixed schema.
1937
1937
  *
1938
- * @param {String} path
1939
- * @return {Boolean}
1938
+ * @param {string} path
1939
+ * @return {boolean}
1940
1940
  * @api private
1941
1941
  */
1942
1942
 
@@ -1957,7 +1957,7 @@ Schema.prototype.hasMixedParent = function(path) {
1957
1957
  /**
1958
1958
  * Setup updatedAt and createdAt timestamps to documents if enabled
1959
1959
  *
1960
- * @param {Boolean|Object} timestamps timestamps options
1960
+ * @param {boolean|object} timestamps timestamps options
1961
1961
  * @api private
1962
1962
  */
1963
1963
  Schema.prototype.setupTimestamp = function(timestamps) {
@@ -1966,8 +1966,8 @@ Schema.prototype.setupTimestamp = function(timestamps) {
1966
1966
 
1967
1967
  /**
1968
1968
  * ignore. Deprecated re: #6405
1969
- * @param {Any} self
1970
- * @param {String} path
1969
+ * @param {any} self
1970
+ * @param {string} path
1971
1971
  * @api private
1972
1972
  */
1973
1973
 
@@ -2053,7 +2053,7 @@ function getPositionalPath(self, path, cleanPath) {
2053
2053
  * const Model = mongoose.model('Test', schema);
2054
2054
  * new Model({ name: 'test' }); // Prints '{"_id": ..., "name": "test" }'
2055
2055
  *
2056
- * @param {String} name name of the document method to call later
2056
+ * @param {string} name name of the document method to call later
2057
2057
  * @param {Array} args arguments to pass to the method
2058
2058
  * @api public
2059
2059
  */
@@ -2096,10 +2096,10 @@ Schema.prototype.queue = function(name, args) {
2096
2096
  * // Runs when you call `doc.deleteOne()`
2097
2097
  * });
2098
2098
  *
2099
- * @param {String|RegExp|String[]} methodName The method name or regular expression to match method name
2100
- * @param {Object} [options]
2101
- * @param {Boolean} [options.document] If `name` is a hook for both document and query middleware, set to `true` to run on document middleware. For example, set `options.document` to `true` to apply this hook to `Document#deleteOne()` rather than `Query#deleteOne()`.
2102
- * @param {Boolean} [options.query] If `name` is a hook for both document and query middleware, set to `true` to run on query middleware.
2099
+ * @param {string|RegExp|string[]} methodName The method name or regular expression to match method name
2100
+ * @param {object} [options]
2101
+ * @param {boolean} [options.document] If `name` is a hook for both document and query middleware, set to `true` to run on document middleware. For example, set `options.document` to `true` to apply this hook to `Document#deleteOne()` rather than `Query#deleteOne()`.
2102
+ * @param {boolean} [options.query] If `name` is a hook for both document and query middleware, set to `true` to run on query middleware.
2103
2103
  * @param {Function} callback
2104
2104
  * @api public
2105
2105
  */
@@ -2150,10 +2150,10 @@ Schema.prototype.pre = function(name) {
2150
2150
  * await m.find();
2151
2151
  * console.log('this fires after the post find hook');
2152
2152
  *
2153
- * @param {String|RegExp|String[]} methodName The method name or regular expression to match method name
2154
- * @param {Object} [options]
2155
- * @param {Boolean} [options.document] If `name` is a hook for both document and query middleware, set to `true` to run on document middleware.
2156
- * @param {Boolean} [options.query] If `name` is a hook for both document and query middleware, set to `true` to run on query middleware.
2153
+ * @param {string|RegExp|string[]} methodName The method name or regular expression to match method name
2154
+ * @param {object} [options]
2155
+ * @param {boolean} [options.document] If `name` is a hook for both document and query middleware, set to `true` to run on document middleware.
2156
+ * @param {boolean} [options.query] If `name` is a hook for both document and query middleware, set to `true` to run on query middleware.
2157
2157
  * @param {Function} fn callback
2158
2158
  * @see middleware https://mongoosejs.com/docs/middleware.html
2159
2159
  * @see kareem https://npmjs.org/package/kareem
@@ -2197,8 +2197,8 @@ Schema.prototype.post = function(name) {
2197
2197
  * mongoose.model('Test', s); // Prints 'Schema Path Name: name'
2198
2198
  *
2199
2199
  * @param {Function} plugin The Plugin's callback
2200
- * @param {Object} [opts] Options to pass to the plugin
2201
- * @param {Boolean} [opts.deduplicate=false] If true, ignore duplicate plugins (same `fn` argument using `===`)
2200
+ * @param {object} [opts] Options to pass to the plugin
2201
+ * @param {boolean} [opts.deduplicate=false] If true, ignore duplicate plugins (same `fn` argument using `===`)
2202
2202
  * @see plugins https://mongoosejs.com/docs/plugins.html
2203
2203
  * @api public
2204
2204
  */
@@ -2253,7 +2253,7 @@ Schema.prototype.plugin = function(fn, opts) {
2253
2253
  *
2254
2254
  * NOTE: `Schema.method()` adds instance methods to the `Schema.methods` object. You can also add instance methods directly to the `Schema.methods` object as seen in the [guide](https://mongoosejs.com/docs/guide.html#methods)
2255
2255
  *
2256
- * @param {String|Object} name The Method Name for a single function, or a Object of "string-function" pairs.
2256
+ * @param {string|object} name The Method Name for a single function, or a Object of "string-function" pairs.
2257
2257
  * @param {Function} [fn] The Function in a single-function definition.
2258
2258
  * @api public
2259
2259
  */
@@ -2298,7 +2298,7 @@ Schema.prototype.method = function(name, fn, options) {
2298
2298
  *
2299
2299
  * If a hash of name/fn pairs is passed as the only argument, each name/fn pair will be added as statics.
2300
2300
  *
2301
- * @param {String|Object} name The Method Name for a single function, or a Object of "string-function" pairs.
2301
+ * @param {string|object} name The Method Name for a single function, or a Object of "string-function" pairs.
2302
2302
  * @param {Function} [fn] The Function in a single-function definition.
2303
2303
  * @api public
2304
2304
  * @see Statics https://mongoosejs.com/docs/guide.html#statics
@@ -2322,10 +2322,10 @@ Schema.prototype.static = function(name, fn) {
2322
2322
  *
2323
2323
  * schema.index({ first: 1, last: -1 })
2324
2324
  *
2325
- * @param {Object} fields The Fields to index, with the order, available values: `1 | -1 | '2d' | '2dsphere' | 'geoHaystack' | 'hashed' | 'text'`
2326
- * @param {Object} [options] Options to pass to [MongoDB driver's `createIndex()` function](https://mongodb.github.io/node-mongodb-native/4.9/classes/Collection.html#createIndex)
2327
- * @param {String | number} [options.expires=null] Mongoose-specific syntactic sugar, uses [ms](https://www.npmjs.com/package/ms) to convert `expires` option into seconds for the `expireAfterSeconds` in the above link.
2328
- * @param {String} [options.language_override=null] Tells mongodb to use the specified field instead of `language` for parsing text indexes.
2325
+ * @param {object} fields The Fields to index, with the order, available values: `1 | -1 | '2d' | '2dsphere' | 'geoHaystack' | 'hashed' | 'text'`
2326
+ * @param {object} [options] Options to pass to [MongoDB driver's `createIndex()` function](https://mongodb.github.io/node-mongodb-native/4.9/classes/Collection.html#createIndex)
2327
+ * @param {string | number} [options.expires=null] Mongoose-specific syntactic sugar, uses [ms](https://www.npmjs.com/package/ms) to convert `expires` option into seconds for the `expireAfterSeconds` in the above link.
2328
+ * @param {string} [options.language_override=null] Tells mongodb to use the specified field instead of `language` for parsing text indexes.
2329
2329
  * @api public
2330
2330
  */
2331
2331
 
@@ -2362,9 +2362,9 @@ Schema.prototype.index = function(fields, options) {
2362
2362
  * schema.set('strict', false); // Sets 'strict' to false
2363
2363
  * schema.set('strict'); // 'false'
2364
2364
  *
2365
- * @param {String} key The name of the option to set the value to
2366
- * @param {Object} [value] The value to set the option to, if not passed, the option will be reset to default
2367
- * @param {Array<string>} [tags] tags to add to read preference if key === 'read'
2365
+ * @param {string} key The name of the option to set the value to
2366
+ * @param {object} [value] The value to set the option to, if not passed, the option will be reset to default
2367
+ * @param {string[]} [tags] tags to add to read preference if key === 'read'
2368
2368
  * @see Schema https://mongoosejs.com/docs/api/schema.html#Schema()
2369
2369
  * @api public
2370
2370
  */
@@ -2455,9 +2455,9 @@ function _propagateOptionsToImplicitlyCreatedSchemas(baseSchema, options) {
2455
2455
  * schema.set('strict', false);
2456
2456
  * schema.get('strict'); // false
2457
2457
  *
2458
- * @param {String} key The name of the Option to get the current value for
2458
+ * @param {string} key The name of the Option to get the current value for
2459
2459
  * @api public
2460
- * @return {Any} the option's value
2460
+ * @return {any} the option's value
2461
2461
  */
2462
2462
 
2463
2463
  Schema.prototype.get = function(key) {
@@ -2469,7 +2469,7 @@ const indexTypes = '2d 2dsphere hashed text'.split(' ');
2469
2469
  /**
2470
2470
  * The allowed index types
2471
2471
  *
2472
- * @property {String[]} indexTypes
2472
+ * @property {string[]} indexTypes
2473
2473
  * @memberOf Schema
2474
2474
  * @static
2475
2475
  * @api public
@@ -2521,16 +2521,16 @@ Schema.prototype.indexes = function() {
2521
2521
  /**
2522
2522
  * Creates a virtual type with the given name.
2523
2523
  *
2524
- * @param {String} name The name of the Virtual
2525
- * @param {Object} [options]
2526
- * @param {String|Model} [options.ref] model name or model instance. Marks this as a [populate virtual](https://mongoosejs.com/docs/populate.html#populate-virtuals).
2527
- * @param {String|Function} [options.localField] Required for populate virtuals. See [populate virtual docs](https://mongoosejs.com/docs/populate.html#populate-virtuals) for more information.
2528
- * @param {String|Function} [options.foreignField] Required for populate virtuals. See [populate virtual docs](https://mongoosejs.com/docs/populate.html#populate-virtuals) for more information.
2529
- * @param {Boolean|Function} [options.justOne=false] Only works with populate virtuals. If [truthy](https://masteringjs.io/tutorials/fundamentals/truthy), will be a single doc or `null`. Otherwise, the populate virtual will be an array.
2530
- * @param {Boolean} [options.count=false] Only works with populate virtuals. If [truthy](https://masteringjs.io/tutorials/fundamentals/truthy), this populate virtual will contain the number of documents rather than the documents themselves when you `populate()`.
2524
+ * @param {string} name The name of the Virtual
2525
+ * @param {object} [options]
2526
+ * @param {string|Model} [options.ref] model name or model instance. Marks this as a [populate virtual](https://mongoosejs.com/docs/populate.html#populate-virtuals).
2527
+ * @param {string|Function} [options.localField] Required for populate virtuals. See [populate virtual docs](https://mongoosejs.com/docs/populate.html#populate-virtuals) for more information.
2528
+ * @param {string|Function} [options.foreignField] Required for populate virtuals. See [populate virtual docs](https://mongoosejs.com/docs/populate.html#populate-virtuals) for more information.
2529
+ * @param {boolean|Function} [options.justOne=false] Only works with populate virtuals. If [truthy](https://masteringjs.io/tutorials/fundamentals/truthy), will be a single doc or `null`. Otherwise, the populate virtual will be an array.
2530
+ * @param {boolean} [options.count=false] Only works with populate virtuals. If [truthy](https://masteringjs.io/tutorials/fundamentals/truthy), this populate virtual will contain the number of documents rather than the documents themselves when you `populate()`.
2531
2531
  * @param {Function|null} [options.get=null] Adds a [getter](https://mongoosejs.com/docs/tutorials/getters-setters.html) to this virtual to transform the populated doc.
2532
- * @param {Object|Function} [options.match=null] Apply a default [`match` option to populate](https://mongoosejs.com/docs/populate.html#match), adding an additional filter to the populate query.
2533
- * @param {Boolean} [options.applyToArray=false] If true and the given `name` is a direct child of an array, apply the virtual to the array rather than the elements.
2532
+ * @param {object|Function} [options.match=null] Apply a default [`match` option to populate](https://mongoosejs.com/docs/populate.html#match), adding an additional filter to the populate query.
2533
+ * @param {boolean} [options.applyToArray=false] If true and the given `name` is a direct child of an array, apply the virtual to the array rather than the elements.
2534
2534
  * @return {VirtualType}
2535
2535
  */
2536
2536
 
@@ -2668,7 +2668,7 @@ Schema.prototype.virtual = function(name, options) {
2668
2668
  /**
2669
2669
  * Returns the virtual type with the given `name`.
2670
2670
  *
2671
- * @param {String} name The name of the Virtual to get
2671
+ * @param {string} name The name of the Virtual to get
2672
2672
  * @return {VirtualType|null}
2673
2673
  */
2674
2674
 
@@ -2692,7 +2692,7 @@ Schema.prototype.virtualpath = function(name) {
2692
2692
  * schema.path('name'); // Undefined
2693
2693
  * schema.path('age'); // Undefined
2694
2694
  *
2695
- * @param {String|Array} path The Path(s) to remove
2695
+ * @param {string|Array} path The Path(s) to remove
2696
2696
  * @return {Schema} the Schema instance
2697
2697
  * @api public
2698
2698
  */
@@ -2750,7 +2750,7 @@ function _deletePath(schema, name) {
2750
2750
  /**
2751
2751
  * Removes the given virtual or virtuals from the schema.
2752
2752
  *
2753
- * @param {String|Array} path The virutal path(s) to remove.
2753
+ * @param {string|Array} path The virutal path(s) to remove.
2754
2754
  * @returns {Schema} the Schema instance, or a mongoose error if the virtual does not exist.
2755
2755
  * @api public
2756
2756
  */
@@ -2815,7 +2815,7 @@ Schema.prototype.removeVirtual = function(path) {
2815
2815
  * ```
2816
2816
  *
2817
2817
  * @param {Function} model The Class to load
2818
- * @param {Boolean} [virtualsOnly] if truthy, only pulls virtuals from the class, not methods or statics
2818
+ * @param {boolean} [virtualsOnly] if truthy, only pulls virtuals from the class, not methods or statics
2819
2819
  */
2820
2820
  Schema.prototype.loadClass = function(model, virtualsOnly) {
2821
2821
  // Stop copying when hit certain base classes
@@ -3109,8 +3109,8 @@ Schema.prototype._preCompile = function _preCompile() {
3109
3109
  * // { required: ['_id'], properties: { name: { bsonType: ['string', 'null'] }, _id: { bsonType: 'objectId' } } }
3110
3110
  * schema.toJSONSchema({ useBsonType: true });
3111
3111
  *
3112
- * @param {Object} [options]
3113
- * @param [Boolean] [options.useBsonType=false] if true, specify each path's type using `bsonType` rather than `type` for MongoDB $jsonSchema support
3112
+ * @param {object} [options]
3113
+ * @param {boolean} [options.useBsonType=false] if true, specify each path's type using `bsonType` rather than `type` for MongoDB $jsonSchema support
3114
3114
  */
3115
3115
 
3116
3116
  Schema.prototype.toJSONSchema = function toJSONSchema(options) {