mongoose 6.4.3 → 6.4.6

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 (52) hide show
  1. package/lib/aggregate.js +3 -2
  2. package/lib/connection.js +9 -9
  3. package/lib/cursor/AggregationCursor.js +3 -2
  4. package/lib/cursor/QueryCursor.js +5 -4
  5. package/lib/document.js +44 -16
  6. package/lib/error/index.js +12 -12
  7. package/lib/error/messages.js +2 -2
  8. package/lib/helpers/query/castUpdate.js +4 -4
  9. package/lib/helpers/timestamps/setDocumentTimestamps.js +26 -0
  10. package/lib/helpers/timestamps/setupTimestamps.js +14 -18
  11. package/lib/helpers/topology/isAtlas.js +14 -9
  12. package/lib/index.js +6 -2
  13. package/lib/model.js +129 -170
  14. package/lib/options/SchemaArrayOptions.js +2 -2
  15. package/lib/options/SchemaBufferOptions.js +1 -1
  16. package/lib/options/SchemaDateOptions.js +3 -3
  17. package/lib/options/SchemaDocumentArrayOptions.js +2 -2
  18. package/lib/options/SchemaMapOptions.js +1 -1
  19. package/lib/options/SchemaNumberOptions.js +4 -4
  20. package/lib/options/SchemaObjectIdOptions.js +2 -2
  21. package/lib/options/SchemaStringOptions.js +8 -8
  22. package/lib/options/SchemaSubdocumentOptions.js +1 -1
  23. package/lib/options/SchemaTypeOptions.js +14 -14
  24. package/lib/options/VirtualOptions.js +11 -11
  25. package/lib/query.js +82 -73
  26. package/lib/schema/SubdocumentPath.js +10 -6
  27. package/lib/schema/array.js +3 -3
  28. package/lib/schema/boolean.js +5 -5
  29. package/lib/schema/buffer.js +2 -2
  30. package/lib/schema/date.js +2 -2
  31. package/lib/schema/decimal128.js +2 -2
  32. package/lib/schema/documentarray.js +12 -8
  33. package/lib/schema/mixed.js +2 -2
  34. package/lib/schema/number.js +2 -2
  35. package/lib/schema/objectid.js +2 -2
  36. package/lib/schema/string.js +2 -2
  37. package/lib/schema.js +76 -34
  38. package/lib/schematype.js +7 -9
  39. package/lib/types/DocumentArray/methods/index.js +1 -1
  40. package/lib/types/buffer.js +8 -4
  41. package/lib/types/decimal128.js +1 -1
  42. package/lib/types/map.js +1 -1
  43. package/lib/types/objectid.js +1 -1
  44. package/lib/types/subdocument.js +1 -1
  45. package/lib/virtualtype.js +5 -5
  46. package/package.json +7 -7
  47. package/types/expressions.d.ts +5 -4
  48. package/types/index.d.ts +9 -7
  49. package/types/indexes.d.ts +2 -2
  50. package/types/inferschematype.d.ts +26 -10
  51. package/types/models.d.ts +2 -1
  52. package/types/query.d.ts +6 -1
@@ -60,8 +60,8 @@ SchemaBuffer._checkRequired = v => !!(v && v.length);
60
60
  * const User = mongoose.model('User', new Schema({ test: Buffer }));
61
61
  * new User({ }).validateSync().errors.test.message; // Path `test` is required.
62
62
  *
63
- * @param {String} option - The option you'd like to set the value for
64
- * @param {*} value - value for option
63
+ * @param {String} option The option you'd like to set the value for
64
+ * @param {Any} value value for option
65
65
  * @return {undefined}
66
66
  * @function set
67
67
  * @static
@@ -60,8 +60,8 @@ SchemaDate._cast = castDate;
60
60
  * const User = mongoose.model('User', new Schema({ test: Date }));
61
61
  * new User({ }).validateSync().errors.test.message; // Path `test` is required.
62
62
  *
63
- * @param {String} option - The option you'd like to set the value for
64
- * @param {*} value - value for option
63
+ * @param {String} option The option you'd like to set the value for
64
+ * @param {Any} value value for option
65
65
  * @return {undefined}
66
66
  * @function set
67
67
  * @static
@@ -56,8 +56,8 @@ Decimal128._cast = castDecimal128;
56
56
  * const User = mongoose.model('User', new Schema({ test: mongoose.Decimal128 }));
57
57
  * new User({ }).validateSync().errors.test.message; // Path `test` is required.
58
58
  *
59
- * @param {String} option - The option you'd like to set the value for
60
- * @param {*} value - value for option
59
+ * @param {String} option The option you'd like to set the value for
60
+ * @param {Any} value value for option
61
61
  * @return {undefined}
62
62
  * @function set
63
63
  * @static
@@ -536,9 +536,9 @@ DocumentArrayPath.prototype.applyGetters = function(value, scope) {
536
536
  * Scopes paths selected in a query to this array.
537
537
  * Necessary for proper default application of subdocument values.
538
538
  *
539
- * @param {DocumentArrayPath} array - the array to scope `fields` paths
540
- * @param {Object|undefined} fields - the root fields selected in the query
541
- * @param {Boolean|undefined} init - if we are being created part of a query result
539
+ * @param {DocumentArrayPath} array the array to scope `fields` paths
540
+ * @param {Object|undefined} fields the root fields selected in the query
541
+ * @param {Boolean|undefined} init if we are being created part of a query result
542
542
  */
543
543
 
544
544
  function scopePaths(array, fields, init) {
@@ -572,6 +572,12 @@ function scopePaths(array, fields, init) {
572
572
  return hasKeys && selected || undefined;
573
573
  }
574
574
 
575
+ /*!
576
+ * ignore
577
+ */
578
+
579
+ DocumentArrayPath.defaultOptions = {};
580
+
575
581
  /**
576
582
  * Sets a default option for all DocumentArray instances.
577
583
  *
@@ -580,16 +586,14 @@ function scopePaths(array, fields, init) {
580
586
  * // Make all numbers have option `min` equal to 0.
581
587
  * mongoose.Schema.DocumentArray.set('_id', false);
582
588
  *
583
- * @param {String} option - The option you'd like to set the value for
584
- * @param {*} value - value for option
585
- * @return {undefined}
589
+ * @param {String} option The name of the option you'd like to set (e.g. trim, lowercase, etc...)
590
+ * @param {Any} value The value of the option you'd like to set.
591
+ * @return {void}
586
592
  * @function set
587
593
  * @static
588
594
  * @api public
589
595
  */
590
596
 
591
- DocumentArrayPath.defaultOptions = {};
592
-
593
597
  DocumentArrayPath.set = SchemaType.set;
594
598
 
595
599
  /*!
@@ -84,8 +84,8 @@ Mixed.get = SchemaType.get;
84
84
  * const User = mongoose.model('User', new Schema({ test: mongoose.Mixed }));
85
85
  * new User({ }).validateSync().errors.test.message; // Path `test` is required.
86
86
  *
87
- * @param {String} option - The option you'd like to set the value for
88
- * @param {*} value - value for option
87
+ * @param {String} option The option you'd like to set the value for
88
+ * @param {Any} value value for option
89
89
  * @return {undefined}
90
90
  * @function set
91
91
  * @static
@@ -57,8 +57,8 @@ SchemaNumber.get = SchemaType.get;
57
57
  * const Order = mongoose.model('Order', new Schema({ amount: Number }));
58
58
  * new Order({ amount: -10 }).validateSync().errors.amount.message; // Path `amount` must be larger than 0.
59
59
  *
60
- * @param {String} option - The option you'd like to set the value for
61
- * @param {*} value - value for option
60
+ * @param {String} option The option you'd like to set the value for
61
+ * @param {Any} value value for option
62
62
  * @return {undefined}
63
63
  * @function set
64
64
  * @static
@@ -84,8 +84,8 @@ ObjectId.get = SchemaType.get;
84
84
  * const Order = mongoose.model('Order', new Schema({ userId: ObjectId }));
85
85
  * new Order({ }).validateSync().errors.userId.message; // Path `userId` is required.
86
86
  *
87
- * @param {String} option - The option you'd like to set the value for
88
- * @param {*} value - value for option
87
+ * @param {String} option The option you'd like to set the value for
88
+ * @param {Any} value value for option
89
89
  * @return {undefined}
90
90
  * @function set
91
91
  * @static
@@ -133,8 +133,8 @@ SchemaString.get = SchemaType.get;
133
133
  * const User = mongoose.model('User', new Schema({ name: String }));
134
134
  * new User({ name: ' John Doe ' }).name; // 'John Doe'
135
135
  *
136
- * @param {String} option - The option you'd like to set the value for
137
- * @param {*} value - value for option
136
+ * @param {String} option The option you'd like to set the value for
137
+ * @param {Any} value value for option
138
138
  * @return {undefined}
139
139
  * @function set
140
140
  * @static
package/lib/schema.js CHANGED
@@ -79,6 +79,7 @@ let id = 0;
79
79
  * - [pluginTags](/docs/guide.html#pluginTags): array of strings - defaults to `undefined`. If set and plugin called with `tags` option, will only apply that plugin to schemas with a matching tag.
80
80
  *
81
81
  * #### Options for Nested Schemas:
82
+ *
82
83
  * - `excludeIndexes`: bool - defaults to `false`. If `true`, skip building indexes on this schema's paths.
83
84
  *
84
85
  * #### Note:
@@ -233,6 +234,7 @@ Object.defineProperty(Schema.prototype, 'childSchemas', {
233
234
  * You do not need to interact with this property at all to use mongoose.
234
235
  *
235
236
  * #### Example:
237
+ *
236
238
  * const schema = new Schema({});
237
239
  * schema.virtual('answer').get(() => 42);
238
240
  *
@@ -272,6 +274,7 @@ Schema.prototype.obj;
272
274
  * in this schema, and the values are instances of the SchemaType class.
273
275
  *
274
276
  * #### Example:
277
+ *
275
278
  * const schema = new Schema({ name: String }, { _id: false });
276
279
  * schema.paths; // { name: SchemaString { ... } }
277
280
  *
@@ -290,6 +293,7 @@ Schema.prototype.paths;
290
293
  * Schema as a tree
291
294
  *
292
295
  * #### Example:
296
+ *
293
297
  * {
294
298
  * '_id' : ObjectId
295
299
  * , 'nested' : {
@@ -395,8 +399,8 @@ Schema.prototype._clone = function _clone(Constructor) {
395
399
  * newSchema.path('name'); // SchemaString { ... }
396
400
  * newSchema.path('age'); // undefined
397
401
  *
398
- * @param {Array} paths list of paths to pick
399
- * @param {Object} [options] options to pass to the schema constructor. Defaults to `this.options` if not set.
402
+ * @param {String[]} paths List of Paths to pick for the new Schema
403
+ * @param {Object} [options] Options to pass to the new Schema Constructor (same as `new Schema(.., Options)`). Defaults to `this.options` if not set.
400
404
  * @return {Schema}
401
405
  * @api public
402
406
  */
@@ -426,8 +430,8 @@ Schema.prototype.pick = function(paths, options) {
426
430
  /**
427
431
  * Returns default options for this schema, merged with `options`.
428
432
  *
429
- * @param {Object} options
430
- * @return {Object}
433
+ * @param {Object} [options] Options to overwrite the default options
434
+ * @return {Object} The merged options of `options` and the default options
431
435
  * @api private
432
436
  */
433
437
 
@@ -550,6 +554,10 @@ Schema.prototype.add = function add(obj, prefix) {
550
554
  const keys = Object.keys(obj);
551
555
  const typeKey = this.options.typeKey;
552
556
  for (const key of keys) {
557
+ if (utils.specialProperties.has(key)) {
558
+ continue;
559
+ }
560
+
553
561
  const fullPath = prefix + key;
554
562
  const val = obj[key];
555
563
 
@@ -755,6 +763,10 @@ Schema.prototype.clearIndexes = function clearIndexes() {
755
763
  *
756
764
  * const schema = new Schema(..);
757
765
  * schema.methods.init = function () {} // potentially breaking
766
+ *
767
+ * @property reserved
768
+ * @memberOf Schema
769
+ * @static
758
770
  */
759
771
 
760
772
  Schema.reserved = Object.create(null);
@@ -788,13 +800,13 @@ reserved.collection = 1;
788
800
  * Sets a path (if arity 2)
789
801
  * Gets a path (if arity 1)
790
802
  *
791
- * #### Example
803
+ * #### Example:
792
804
  *
793
805
  * schema.path('name') // returns a SchemaType
794
806
  * schema.path('name', Number) // changes the schemaType of `name` to Number
795
807
  *
796
- * @param {String} path
797
- * @param {Object} constructor
808
+ * @param {String} path The name of the Path to get / set
809
+ * @param {Object} [obj] The Type to set the path to, if provided the path will be SET, otherwise the path will be GET
798
810
  * @api public
799
811
  */
800
812
 
@@ -846,6 +858,9 @@ Schema.prototype.path = function(path, obj) {
846
858
  let fullPath = '';
847
859
 
848
860
  for (const sub of subpaths) {
861
+ if (utils.specialProperties.has(sub)) {
862
+ throw new Error('Cannot set special property `' + sub + '` on a schema');
863
+ }
849
864
  fullPath = fullPath += (fullPath.length > 0 ? '.' : '') + sub;
850
865
  if (!branch[sub]) {
851
866
  this.nested[fullPath] = true;
@@ -1059,6 +1074,7 @@ Object.defineProperty(Schema.prototype, 'base', {
1059
1074
  *
1060
1075
  * @param {String} path
1061
1076
  * @param {Object} obj constructor
1077
+ * @param {Object} options
1062
1078
  * @api private
1063
1079
  */
1064
1080
 
@@ -1316,6 +1332,7 @@ Schema.prototype.eachPath = function(fn) {
1316
1332
  * Returns an Array of path strings that are required by this schema.
1317
1333
  *
1318
1334
  * #### Example:
1335
+ *
1319
1336
  * const s = new Schema({
1320
1337
  * name: { type: String, required: true },
1321
1338
  * age: { type: String, required: true },
@@ -1324,7 +1341,7 @@ Schema.prototype.eachPath = function(fn) {
1324
1341
  * s.requiredPaths(); // [ 'age', 'name' ]
1325
1342
  *
1326
1343
  * @api public
1327
- * @param {Boolean} invalidate refresh the cache
1344
+ * @param {Boolean} invalidate Refresh the cache
1328
1345
  * @return {Array}
1329
1346
  */
1330
1347
 
@@ -1545,7 +1562,7 @@ Schema.prototype.queue = function(name, args) {
1545
1562
  /**
1546
1563
  * Defines a pre hook for the model.
1547
1564
  *
1548
- * #### Example
1565
+ * #### Example:
1549
1566
  *
1550
1567
  * const toySchema = new Schema({ name: String, created: Date });
1551
1568
  *
@@ -1577,7 +1594,7 @@ Schema.prototype.queue = function(name, args) {
1577
1594
  * // Runs when you call `doc.deleteOne()`
1578
1595
  * });
1579
1596
  *
1580
- * @param {String|RegExp} The method name or regular expression to match method name
1597
+ * @param {String|RegExp|String[]} methodName The method name or regular expression to match method name
1581
1598
  * @param {Object} [options]
1582
1599
  * @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()`.
1583
1600
  * @param {Boolean} [options.query] If `name` is a hook for both document and query middleware, set to `true` to run on query middleware.
@@ -1633,7 +1650,7 @@ Schema.prototype.pre = function(name) {
1633
1650
  * console.log('this fires after the post find hook');
1634
1651
  * });
1635
1652
  *
1636
- * @param {String|RegExp} The method name or regular expression to match method name
1653
+ * @param {String|RegExp|String[]} methodName The method name or regular expression to match method name
1637
1654
  * @param {Object} [options]
1638
1655
  * @param {Boolean} [options.document] If `name` is a hook for both document and query middleware, set to `true` to run on document middleware.
1639
1656
  * @param {Boolean} [options.query] If `name` is a hook for both document and query middleware, set to `true` to run on query middleware.
@@ -1673,8 +1690,14 @@ Schema.prototype.post = function(name) {
1673
1690
  * s.plugin(schema => console.log(schema.path('name').path));
1674
1691
  * mongoose.model('Test', s); // Prints 'name'
1675
1692
  *
1676
- * @param {Function} plugin callback
1677
- * @param {Object} [opts]
1693
+ * Or with Options:
1694
+ *
1695
+ * const s = new Schema({ name: String });
1696
+ * s.plugin((schema, opts) => console.log(opts.text, schema.path('name').path), { text: "Schema Path Name:" });
1697
+ * mongoose.model('Test', s); // Prints 'Schema Path Name: name'
1698
+ *
1699
+ * @param {Function} plugin The Plugin's callback
1700
+ * @param {Object} [opts] Options to pass to the plugin
1678
1701
  * @see plugins
1679
1702
  * @api public
1680
1703
  */
@@ -1701,7 +1724,7 @@ Schema.prototype.plugin = function(fn, opts) {
1701
1724
  /**
1702
1725
  * Adds an instance method to documents constructed from Models compiled from this schema.
1703
1726
  *
1704
- * #### Example
1727
+ * #### Example:
1705
1728
  *
1706
1729
  * const schema = kittySchema = new Schema(..);
1707
1730
  *
@@ -1722,13 +1745,14 @@ Schema.prototype.plugin = function(fn, opts) {
1722
1745
  * });
1723
1746
  *
1724
1747
  * // later
1748
+ * const fizz = new Kitty;
1725
1749
  * fizz.purr();
1726
1750
  * fizz.scratch();
1727
1751
  *
1728
1752
  * 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](/docs/guide.html#methods)
1729
1753
  *
1730
- * @param {String|Object} method name
1731
- * @param {Function} [fn]
1754
+ * @param {String|Object} name The Method Name for a single function, or a Object of "string-function" pairs.
1755
+ * @param {Function} [fn] The Function in a single-function definition.
1732
1756
  * @api public
1733
1757
  */
1734
1758
 
@@ -1748,7 +1772,7 @@ Schema.prototype.method = function(name, fn, options) {
1748
1772
  /**
1749
1773
  * Adds static "class" methods to Models compiled from this schema.
1750
1774
  *
1751
- * #### Example
1775
+ * #### Example:
1752
1776
  *
1753
1777
  * const schema = new Schema(..);
1754
1778
  * // Equivalent to `schema.statics.findByName = function(name) {}`;
@@ -1759,10 +1783,21 @@ Schema.prototype.method = function(name, fn, options) {
1759
1783
  * const Drink = mongoose.model('Drink', schema);
1760
1784
  * await Drink.findByName('LaCroix');
1761
1785
  *
1786
+ * If a hash of name/fn pairs is passed as the only argument, each name/fn pair will be added as methods.
1787
+ *
1788
+ * schema.static({
1789
+ * findByName: function () {..}
1790
+ * , findByCost: function () {..}
1791
+ * });
1792
+ *
1793
+ * const Drink = mongoose.model('Drink', schema);
1794
+ * await Drink.findByName('LaCroix');
1795
+ * await Drink.findByCost(3);
1796
+ *
1762
1797
  * If a hash of name/fn pairs is passed as the only argument, each name/fn pair will be added as statics.
1763
1798
  *
1764
- * @param {String|Object} name
1765
- * @param {Function} [fn]
1799
+ * @param {String|Object} name The Method Name for a single function, or a Object of "string-function" pairs.
1800
+ * @param {Function} [fn] The Function in a single-function definition.
1766
1801
  * @api public
1767
1802
  * @see Statics /docs/guide.html#statics
1768
1803
  */
@@ -1781,11 +1816,11 @@ Schema.prototype.static = function(name, fn) {
1781
1816
  /**
1782
1817
  * Defines an index (most likely compound) for this schema.
1783
1818
  *
1784
- * #### Example
1819
+ * #### Example:
1785
1820
  *
1786
1821
  * schema.index({ first: 1, last: -1 })
1787
1822
  *
1788
- * @param {Object} fields
1823
+ * @param {Object} fields The Fields to index, with the order, available values: `1 | -1 | '2d' | '2dsphere' | 'geoHaystack' | 'hashed' | 'text'`
1789
1824
  * @param {Object} [options] Options to pass to [MongoDB driver's `createIndex()` function](https://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#createIndex)
1790
1825
  * @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.
1791
1826
  * @api public
@@ -1806,14 +1841,14 @@ Schema.prototype.index = function(fields, options) {
1806
1841
  /**
1807
1842
  * Sets a schema option.
1808
1843
  *
1809
- * #### Example
1844
+ * #### Example:
1810
1845
  *
1811
1846
  * schema.set('strict'); // 'true' by default
1812
1847
  * schema.set('strict', false); // Sets 'strict' to false
1813
1848
  * schema.set('strict'); // 'false'
1814
1849
  *
1815
- * @param {String} key option name
1816
- * @param {Object} [value] if not passed, the current option value is returned
1850
+ * @param {String} key The name of the option to set the value to
1851
+ * @param {Object} [value] The value to set the option to, if not passed, the option will be reset to default
1817
1852
  * @see Schema ./
1818
1853
  * @api public
1819
1854
  */
@@ -1861,7 +1896,7 @@ Schema.prototype.set = function(key, value, _tags) {
1861
1896
  * schema.set('strict', false);
1862
1897
  * schema.get('strict'); // false
1863
1898
  *
1864
- * @param {String} key option name
1899
+ * @param {String} key The name of the Option to get the current value for
1865
1900
  * @api public
1866
1901
  * @return {Any} the option's value
1867
1902
  */
@@ -1870,16 +1905,17 @@ Schema.prototype.get = function(key) {
1870
1905
  return this.options[key];
1871
1906
  };
1872
1907
 
1908
+ const indexTypes = '2d 2dsphere hashed text'.split(' ');
1909
+
1873
1910
  /**
1874
1911
  * The allowed index types
1875
1912
  *
1876
- * @receiver Schema
1877
- * @static indexTypes
1913
+ * @property {String[]} indexTypes
1914
+ * @memberOf Schema
1915
+ * @static
1878
1916
  * @api public
1879
1917
  */
1880
1918
 
1881
- const indexTypes = '2d 2dsphere hashed text'.split(' ');
1882
-
1883
1919
  Object.defineProperty(Schema, 'indexTypes', {
1884
1920
  get: function() {
1885
1921
  return indexTypes;
@@ -1926,7 +1962,7 @@ Schema.prototype.indexes = function() {
1926
1962
  /**
1927
1963
  * Creates a virtual type with the given name.
1928
1964
  *
1929
- * @param {String} name
1965
+ * @param {String} name The name of the Virtual
1930
1966
  * @param {Object} [options]
1931
1967
  * @param {String|Model} [options.ref] model name or model instance. Marks this as a [populate virtual](/docs/populate.html#populate-virtuals).
1932
1968
  * @param {String|Function} [options.localField] Required for populate virtuals. See [populate virtual docs](/docs/populate.html#populate-virtuals) for more information.
@@ -2044,8 +2080,8 @@ Schema.prototype.virtual = function(name, options) {
2044
2080
  /**
2045
2081
  * Returns the virtual type with the given `name`.
2046
2082
  *
2047
- * @param {String} name
2048
- * @return {VirtualType}
2083
+ * @param {String} name The name of the Virtual to get
2084
+ * @return {VirtualType|null}
2049
2085
  */
2050
2086
 
2051
2087
  Schema.prototype.virtualpath = function(name) {
@@ -2062,7 +2098,13 @@ Schema.prototype.virtualpath = function(name) {
2062
2098
  * schema.path('name'); // Undefined
2063
2099
  * schema.path('age'); // SchemaNumber { ... }
2064
2100
  *
2065
- * @param {String|Array} path
2101
+ * Or as a Array:
2102
+ *
2103
+ * schema.remove(['name', 'age']);
2104
+ * schema.path('name'); // Undefined
2105
+ * schema.path('age'); // Undefined
2106
+ *
2107
+ * @param {String|Array} path The Path(s) to remove
2066
2108
  * @return {Schema} the Schema instance
2067
2109
  * @api public
2068
2110
  */
@@ -2150,7 +2192,7 @@ function _deletePath(schema, name) {
2150
2192
  * userSchema.loadClass(UserClass);
2151
2193
  * ```
2152
2194
  *
2153
- * @param {Function} model
2195
+ * @param {Function} model The Class to load
2154
2196
  * @param {Boolean} [virtualsOnly] if truthy, only pulls virtuals from the class, not methods or statics
2155
2197
  */
2156
2198
  Schema.prototype.loadClass = function(model, virtualsOnly) {
package/lib/schematype.js CHANGED
@@ -206,7 +206,7 @@ SchemaType.prototype.splitPath = function() {
206
206
  * @param {Function|false} caster Function that casts arbitrary values to this type, or throws an error if casting failed
207
207
  * @return {Function}
208
208
  * @static
209
- * @receiver SchemaType
209
+ * @memberOf SchemaType
210
210
  * @function cast
211
211
  * @api public
212
212
  */
@@ -239,9 +239,7 @@ SchemaType.cast = function cast(caster) {
239
239
  *
240
240
  * @param {Function|false} caster Function that casts arbitrary values to this type, or throws an error if casting failed
241
241
  * @return {Function}
242
- * @static
243
- * @receiver SchemaType
244
- * @function cast
242
+ * @memberOf SchemaType
245
243
  * @api public
246
244
  */
247
245
 
@@ -279,10 +277,10 @@ SchemaType.prototype.cast = function cast() {
279
277
  * mongoose.SchemaTypes.String.set('trim', true);
280
278
  *
281
279
  * @param {String} option The name of the option you'd like to set (e.g. trim, lowercase, etc...)
282
- * @param {*} value The value of the option you'd like to set.
280
+ * @param {Any} value The value of the option you'd like to set.
283
281
  * @return {void}
284
282
  * @static
285
- * @receiver SchemaType
283
+ * @memberOf SchemaType
286
284
  * @function set
287
285
  * @api public
288
286
  */
@@ -305,7 +303,7 @@ SchemaType.set = function set(option, value) {
305
303
  * @param {Function} getter
306
304
  * @return {this}
307
305
  * @static
308
- * @receiver SchemaType
306
+ * @memberOf SchemaType
309
307
  * @function get
310
308
  * @api public
311
309
  */
@@ -1244,7 +1242,7 @@ SchemaType.prototype.select = function select(val) {
1244
1242
  * @param {any} value
1245
1243
  * @param {Function} callback
1246
1244
  * @param {Object} scope
1247
- * @api private
1245
+ * @api public
1248
1246
  */
1249
1247
 
1250
1248
  SchemaType.prototype.doValidate = function(value, fn, scope, options) {
@@ -1636,7 +1634,7 @@ SchemaType.prototype._castForQuery = function(val) {
1636
1634
  * @param {Function} fn
1637
1635
  * @return {Function}
1638
1636
  * @static
1639
- * @receiver SchemaType
1637
+ * @memberOf SchemaType
1640
1638
  * @function checkRequired
1641
1639
  * @api public
1642
1640
  */
@@ -35,7 +35,7 @@ const methods = {
35
35
  *
36
36
  * @method _cast
37
37
  * @api private
38
- * @receiver MongooseDocumentArray
38
+ * @memberOf MongooseDocumentArray
39
39
  */
40
40
 
41
41
  _cast(value, index) {
@@ -70,7 +70,8 @@ MongooseBuffer.mixin = {
70
70
  *
71
71
  * @api private
72
72
  * @property _subtype
73
- * @memberOf MongooseBuffer
73
+ * @memberOf MongooseBuffer.mixin
74
+ * @static
74
75
  */
75
76
 
76
77
  _subtype: undefined,
@@ -80,7 +81,8 @@ MongooseBuffer.mixin = {
80
81
  *
81
82
  * @api private
82
83
  * @method _markModified
83
- * @memberOf MongooseBuffer
84
+ * @memberOf MongooseBuffer.mixin
85
+ * @static
84
86
  */
85
87
 
86
88
  _markModified: function() {
@@ -97,7 +99,8 @@ MongooseBuffer.mixin = {
97
99
  *
98
100
  * @api public
99
101
  * @method write
100
- * @memberOf MongooseBuffer
102
+ * @memberOf MongooseBuffer.mixin
103
+ * @static
101
104
  */
102
105
 
103
106
  write: function() {
@@ -120,7 +123,8 @@ MongooseBuffer.mixin = {
120
123
  * @return {Number} The number of bytes copied.
121
124
  * @param {Buffer} target
122
125
  * @method copy
123
- * @memberOf MongooseBuffer
126
+ * @memberOf MongooseBuffer.mixin
127
+ * @static
124
128
  */
125
129
 
126
130
  copy: function(target) {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Decimal128 type constructor
3
3
  *
4
- * #### Example
4
+ * #### Example:
5
5
  *
6
6
  * const id = new mongoose.Types.Decimal128('3.1415');
7
7
  *
package/lib/types/map.js CHANGED
@@ -275,7 +275,7 @@ Object.defineProperty(MongooseMap.prototype, '$__schemaType', {
275
275
  *
276
276
  * @api public
277
277
  * @property $isMongooseMap
278
- * @memberOf Map
278
+ * @memberOf MongooseMap
279
279
  * @instance
280
280
  */
281
281
 
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * ObjectId type constructor
3
3
  *
4
- * #### Example
4
+ * #### Example:
5
5
  *
6
6
  * const id = new mongoose.Types.ObjectId;
7
7
  *
@@ -188,7 +188,7 @@ Subdocument.prototype.isModified = function(paths, modifiedPaths) {
188
188
  * @param {String} path the field to mark as valid
189
189
  * @api private
190
190
  * @method $markValid
191
- * @receiver Subdocument
191
+ * @memberOf Subdocument
192
192
  */
193
193
 
194
194
  Subdocument.prototype.$markValid = function(path) {
@@ -75,7 +75,7 @@ VirtualType.prototype.clone = function() {
75
75
  * Mongoose calls the getter function with the below 3 parameters.
76
76
  *
77
77
  * - `value`: the value returned by the previous getter. If there is only one getter, `value` will be `undefined`.
78
- * - `virtual`: the virtual object you called `.get()` on
78
+ * - `virtual`: the virtual object you called `.get()` on.
79
79
  * - `doc`: the document this virtual is attached to. Equivalent to `this`.
80
80
  *
81
81
  * #### Example:
@@ -85,7 +85,7 @@ VirtualType.prototype.clone = function() {
85
85
  * return this.name.first + ' ' + this.name.last;
86
86
  * });
87
87
  *
88
- * @param {Function(Any, VirtualType, Document)} fn
88
+ * @param {function} fn
89
89
  * @return {VirtualType} this
90
90
  * @api public
91
91
  */
@@ -100,8 +100,8 @@ VirtualType.prototype.get = function(fn) {
100
100
  *
101
101
  * Mongoose calls the setter function with the below 3 parameters.
102
102
  *
103
- * - `value`: the value being set
104
- * - `virtual`: the virtual object you're calling `.set()` on
103
+ * - `value`: the value being set.
104
+ * - `virtual`: the virtual object you're calling `.set()` on.
105
105
  * - `doc`: the document this virtual is attached to. Equivalent to `this`.
106
106
  *
107
107
  * #### Example:
@@ -120,7 +120,7 @@ VirtualType.prototype.get = function(fn) {
120
120
  * doc.name.first; // 'Jean-Luc'
121
121
  * doc.name.last; // 'Picard'
122
122
  *
123
- * @param {Function(Any, VirtualType, Document)} fn
123
+ * @param {function} fn
124
124
  * @return {VirtualType} this
125
125
  * @api public
126
126
  */