mongoose 6.5.3 → 6.5.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 (80) hide show
  1. package/.mocharc.yml +2 -0
  2. package/lib/aggregate.js +2 -1
  3. package/lib/cast/boolean.js +1 -1
  4. package/lib/cast/number.js +1 -1
  5. package/lib/cast/string.js +1 -1
  6. package/lib/cast.js +3 -0
  7. package/lib/connection.js +9 -1
  8. package/lib/cursor/AggregationCursor.js +14 -3
  9. package/lib/cursor/QueryCursor.js +14 -3
  10. package/lib/document.js +27 -14
  11. package/lib/drivers/browser/objectid.js +2 -1
  12. package/lib/drivers/node-mongodb-native/ReadPreference.js +1 -1
  13. package/lib/drivers/node-mongodb-native/collection.js +6 -2
  14. package/lib/error/browserMissingSchema.js +1 -1
  15. package/lib/error/cast.js +2 -1
  16. package/lib/error/divergentArray.js +2 -1
  17. package/lib/error/missingSchema.js +2 -1
  18. package/lib/error/notFound.js +2 -1
  19. package/lib/error/overwriteModel.js +2 -1
  20. package/lib/error/validation.js +9 -7
  21. package/lib/error/validator.js +8 -4
  22. package/lib/helpers/clone.js +1 -1
  23. package/lib/helpers/discriminator/getConstructor.js +2 -1
  24. package/lib/helpers/discriminator/getDiscriminatorByValue.js +7 -6
  25. package/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +7 -6
  26. package/lib/helpers/document/compile.js +14 -2
  27. package/lib/helpers/document/getEmbeddedDiscriminatorPath.js +5 -1
  28. package/lib/helpers/get.js +2 -1
  29. package/lib/helpers/getConstructorName.js +2 -1
  30. package/lib/helpers/isBsonType.js +2 -1
  31. package/lib/helpers/isMongooseObject.js +2 -2
  32. package/lib/helpers/isObject.js +1 -1
  33. package/lib/helpers/isSimpleValidator.js +1 -1
  34. package/lib/helpers/model/applyHooks.js +3 -1
  35. package/lib/helpers/model/applyMethods.js +2 -1
  36. package/lib/helpers/model/applyStatics.js +2 -1
  37. package/lib/helpers/model/castBulkWrite.js +7 -2
  38. package/lib/helpers/model/discriminator.js +3 -1
  39. package/lib/helpers/pluralize.js +1 -1
  40. package/lib/helpers/populate/assignRawDocsToIdStructure.js +5 -3
  41. package/lib/helpers/populate/assignVals.js +14 -3
  42. package/lib/helpers/populate/createPopulateQueryFilter.js +8 -2
  43. package/lib/helpers/populate/getModelsMapForPopulate.js +3 -1
  44. package/lib/helpers/populate/getSchemaTypes.js +3 -1
  45. package/lib/helpers/populate/markArraySubdocsPopulated.js +5 -1
  46. package/lib/helpers/projection/hasIncludedChildren.js +4 -1
  47. package/lib/helpers/projection/isPathExcluded.js +3 -2
  48. package/lib/helpers/projection/isSubpath.js +2 -1
  49. package/lib/helpers/query/applyQueryMiddleware.js +3 -2
  50. package/lib/helpers/query/castUpdate.js +14 -8
  51. package/lib/helpers/query/completeMany.js +3 -2
  52. package/lib/helpers/query/getEmbeddedDiscriminatorPath.js +7 -1
  53. package/lib/helpers/query/wrapThunk.js +3 -1
  54. package/lib/helpers/schema/getIndexes.js +7 -2
  55. package/lib/helpers/schema/getPath.js +4 -3
  56. package/lib/helpers/schema/idGetter.js +2 -1
  57. package/lib/index.js +10 -2
  58. package/lib/model.js +60 -26
  59. package/lib/query.js +124 -29
  60. package/lib/queryhelpers.js +4 -4
  61. package/lib/schema/SubdocumentPath.js +1 -1
  62. package/lib/schema/array.js +1 -1
  63. package/lib/schema/date.js +2 -1
  64. package/lib/schema/documentarray.js +3 -2
  65. package/lib/schema/operators/helpers.js +2 -2
  66. package/lib/schema/operators/text.js +1 -1
  67. package/lib/schema.js +11 -3
  68. package/lib/schematype.js +17 -4
  69. package/lib/statemachine.js +13 -12
  70. package/lib/types/ArraySubdocument.js +13 -3
  71. package/lib/types/DocumentArray/methods/index.js +7 -3
  72. package/lib/types/array/methods/index.js +1 -0
  73. package/lib/types/map.js +3 -1
  74. package/lib/types/objectid.js +2 -2
  75. package/lib/types/subdocument.js +30 -8
  76. package/lib/utils.js +58 -31
  77. package/package.json +1 -1
  78. package/types/document.d.ts +1 -1
  79. package/types/middlewares.d.ts +1 -1
  80. package/types/models.d.ts +1 -1
package/.mocharc.yml ADDED
@@ -0,0 +1,2 @@
1
+ reporter: spec # better to identify failing / slow tests than "dot"
2
+ ui: bdd # explicitly setting, even though it is mocha default
package/lib/aggregate.js CHANGED
@@ -1104,12 +1104,13 @@ function isOperator(obj) {
1104
1104
  return k.length === 1 && k[0][0] === '$';
1105
1105
  }
1106
1106
 
1107
- /*!
1107
+ /**
1108
1108
  * Adds the appropriate `$match` pipeline step to the top of an aggregate's
1109
1109
  * pipeline, should it's model is a non-root discriminator type. This is
1110
1110
  * analogous to the `prepareDiscriminatorCriteria` function in `lib/query.js`.
1111
1111
  *
1112
1112
  * @param {Aggregate} aggregate Aggregate to prepare
1113
+ * @api private
1113
1114
  */
1114
1115
 
1115
1116
  Aggregate._prepareDiscriminatorPipeline = prepareDiscriminatorPipeline;
@@ -2,7 +2,7 @@
2
2
 
3
3
  const CastError = require('../error/cast');
4
4
 
5
- /*!
5
+ /**
6
6
  * Given a value, cast it to a boolean, or throw a `CastError` if the value
7
7
  * cannot be casted. `null` and `undefined` are considered valid.
8
8
  *
@@ -2,7 +2,7 @@
2
2
 
3
3
  const assert = require('assert');
4
4
 
5
- /*!
5
+ /**
6
6
  * Given a value, cast it to a number, or throw an `Error` if the value
7
7
  * cannot be casted. `null` and `undefined` are considered valid.
8
8
  *
@@ -2,7 +2,7 @@
2
2
 
3
3
  const CastError = require('../error/cast');
4
4
 
5
- /*!
5
+ /**
6
6
  * Given a value, cast it to a string, or throw a `CastError` if the value
7
7
  * cannot be casted. `null` and `undefined` are considered valid.
8
8
  *
package/lib/cast.js CHANGED
@@ -25,6 +25,9 @@ const ALLOWED_GEOWITHIN_GEOJSON_TYPES = ['Polygon', 'MultiPolygon'];
25
25
  * @param {Schema} schema
26
26
  * @param {Object} obj Object to cast
27
27
  * @param {Object} [options] the query options
28
+ * @param {Boolean|"throw"} [options.strict] Wheter to enable all strict options
29
+ * @param {Boolean|"throw"} [options.strictQuery] Enable strict Queries
30
+ * @param {Boolean} [options.upsert]
28
31
  * @param {Query} [context] passed to setters
29
32
  * @api private
30
33
  */
package/lib/connection.js CHANGED
@@ -26,7 +26,7 @@ const processConnectionOptions = require('./helpers/processConnectionOptions');
26
26
  const arrayAtomicsSymbol = require('./helpers/symbols').arrayAtomicsSymbol;
27
27
  const sessionNewDocuments = require('./helpers/symbols').sessionNewDocuments;
28
28
 
29
- /*!
29
+ /**
30
30
  * A list of authentication mechanisms that don't require a password for authentication.
31
31
  * This is used by the authMechanismDoesNotRequirePassword method.
32
32
  *
@@ -1230,6 +1230,14 @@ Connection.prototype.model = function(name, schema, collection, options) {
1230
1230
  return sub;
1231
1231
  }
1232
1232
 
1233
+ if (arguments.length === 1) {
1234
+ model = this.models[name];
1235
+ if (!model) {
1236
+ throw new MongooseError.MissingSchemaError(name);
1237
+ }
1238
+ return model;
1239
+ }
1240
+
1233
1241
  if (!model) {
1234
1242
  throw new MongooseError.MissingSchemaError(name);
1235
1243
  }
@@ -71,8 +71,12 @@ function _init(model, c, agg) {
71
71
  }
72
72
  }
73
73
 
74
- /*!
74
+ /**
75
75
  * Necessary to satisfy the Readable API
76
+ * @method _read
77
+ * @memberOf AggregationCursor
78
+ * @instance
79
+ * @api private
76
80
  */
77
81
 
78
82
  AggregationCursor.prototype._read = function() {
@@ -147,8 +151,12 @@ Object.defineProperty(AggregationCursor.prototype, 'map', {
147
151
  writable: true
148
152
  });
149
153
 
150
- /*!
154
+ /**
151
155
  * Marks this cursor as errored
156
+ * @method _markError
157
+ * @instance
158
+ * @memberOf AggregationCursor
159
+ * @api private
152
160
  */
153
161
 
154
162
  AggregationCursor.prototype._markError = function(error) {
@@ -324,9 +332,12 @@ function _waitForCursor(ctx, cb) {
324
332
  });
325
333
  }
326
334
 
327
- /*!
335
+ /**
328
336
  * Get the next doc from the underlying cursor and mongooseify it
329
337
  * (populate, etc.)
338
+ * @param {Any} ctx
339
+ * @param {Function} cb
340
+ * @api private
330
341
  */
331
342
 
332
343
  function _next(ctx, cb) {
@@ -85,8 +85,12 @@ function QueryCursor(query, options) {
85
85
 
86
86
  util.inherits(QueryCursor, Readable);
87
87
 
88
- /*!
88
+ /**
89
89
  * Necessary to satisfy the Readable API
90
+ * @method _read
91
+ * @memberOf QueryCursor
92
+ * @instance
93
+ * @api private
90
94
  */
91
95
 
92
96
  QueryCursor.prototype._read = function() {
@@ -152,8 +156,12 @@ Object.defineProperty(QueryCursor.prototype, 'map', {
152
156
  writable: true
153
157
  });
154
158
 
155
- /*!
159
+ /**
156
160
  * Marks this cursor as errored
161
+ * @method _markError
162
+ * @memberOf QueryCursor
163
+ * @instance
164
+ * @api private
157
165
  */
158
166
 
159
167
  QueryCursor.prototype._markError = function(error) {
@@ -340,9 +348,12 @@ function _transformForAsyncIterator(doc) {
340
348
  return doc == null ? { done: true } : { value: doc, done: false };
341
349
  }
342
350
 
343
- /*!
351
+ /**
344
352
  * Get the next doc from the underlying cursor and mongooseify it
345
353
  * (populate, etc.)
354
+ * @param {Any} ctx
355
+ * @param {Function} cb
356
+ * @api private
346
357
  */
347
358
 
348
359
  function _next(ctx, cb) {
package/lib/document.js CHANGED
@@ -696,12 +696,15 @@ Document.prototype.$__init = function(doc, opts) {
696
696
  return this;
697
697
  };
698
698
 
699
- /*!
699
+ /**
700
700
  * Init helper.
701
701
  *
702
702
  * @param {Object} self document instance
703
703
  * @param {Object} obj raw mongodb doc
704
704
  * @param {Object} doc object we are initializing
705
+ * @param {Object} [opts] Optional Options
706
+ * @param {Boolean} [opts.setters] Call `applySetters` instead of `cast`
707
+ * @param {String} [prefix] Prefix to add to each path
705
708
  * @api private
706
709
  */
707
710
 
@@ -3815,11 +3818,12 @@ Document.prototype.toObject = function(options) {
3815
3818
  return this.$toObject(options);
3816
3819
  };
3817
3820
 
3818
- /*!
3821
+ /**
3819
3822
  * Minimizes an object, removing undefined values and empty objects
3820
3823
  *
3821
3824
  * @param {Object} object to minimize
3822
3825
  * @return {Object}
3826
+ * @api private
3823
3827
  */
3824
3828
 
3825
3829
  function minimize(obj) {
@@ -3925,12 +3929,14 @@ function applyVirtuals(self, json, options, toObjectOptions) {
3925
3929
  }
3926
3930
 
3927
3931
 
3928
- /*!
3932
+ /**
3929
3933
  * Applies virtuals properties to `json`.
3930
3934
  *
3931
3935
  * @param {Document} self
3932
3936
  * @param {Object} json
3937
+ * @param {Object} [options]
3933
3938
  * @return {Object} `json`
3939
+ * @api private
3934
3940
  */
3935
3941
 
3936
3942
  function applyGetters(self, json, options) {
@@ -3980,12 +3986,13 @@ function applyGetters(self, json, options) {
3980
3986
  return json;
3981
3987
  }
3982
3988
 
3983
- /*!
3989
+ /**
3984
3990
  * Applies schema type transforms to `json`.
3985
3991
  *
3986
3992
  * @param {Document} self
3987
3993
  * @param {Object} json
3988
3994
  * @return {Object} `json`
3995
+ * @api private
3989
3996
  */
3990
3997
 
3991
3998
  function applySchemaTypeTransforms(self, json) {
@@ -4158,10 +4165,7 @@ Document.prototype.inspect = function(options) {
4158
4165
  };
4159
4166
 
4160
4167
  if (inspect.custom) {
4161
- /*!
4162
- * Avoid Node deprecation warning DEP0079
4163
- */
4164
-
4168
+ // Avoid Node deprecation warning DEP0079
4165
4169
  Document.prototype[inspect.custom] = Document.prototype.inspect;
4166
4170
  }
4167
4171
 
@@ -4417,8 +4421,13 @@ Document.prototype.$populated = Document.prototype.populated;
4417
4421
  * doc.$assertPopulated('author'); // does not throw
4418
4422
  * doc.$assertPopulated('other path'); // throws an error
4419
4423
  *
4424
+ * // Manually populate and assert in one call. The following does
4425
+ * // `doc.$set({ likes })` before asserting.
4426
+ * doc.$assertPopulated('likes', { likes });
4420
4427
  *
4421
- * @param {String|String[]} paths
4428
+ *
4429
+ * @param {String|String[]} path path or array of paths to check. `$assertPopulated` throws if any of the given paths is not populated.
4430
+ * @param {Object} [values] optional values to `$set()`. Convenient if you want to manually populate a path and assert that the path was populated in 1 call.
4422
4431
  * @return {Document} this
4423
4432
  * @memberOf Document
4424
4433
  * @method $assertPopulated
@@ -4426,14 +4435,18 @@ Document.prototype.$populated = Document.prototype.populated;
4426
4435
  * @api public
4427
4436
  */
4428
4437
 
4429
- Document.prototype.$assertPopulated = function $assertPopulated(paths) {
4430
- if (Array.isArray(paths)) {
4431
- paths.forEach(path => this.$assertPopulated(path));
4438
+ Document.prototype.$assertPopulated = function $assertPopulated(path, values) {
4439
+ if (Array.isArray(path)) {
4440
+ path.forEach(p => this.$assertPopulated(p, values));
4432
4441
  return this;
4433
4442
  }
4434
4443
 
4435
- if (!this.$populated(paths)) {
4436
- throw new MongooseError(`Expected path "${paths}" to be populated`);
4444
+ if (arguments.length > 1) {
4445
+ this.$set(values);
4446
+ }
4447
+
4448
+ if (!this.$populated(path)) {
4449
+ throw new MongooseError(`Expected path "${path}" to be populated`);
4437
4450
  }
4438
4451
 
4439
4452
  return this;
@@ -9,8 +9,9 @@
9
9
 
10
10
  const ObjectId = require('bson').ObjectID;
11
11
 
12
- /*!
12
+ /**
13
13
  * Getter for convenience with populate, see gh-6115
14
+ * @api private
14
15
  */
15
16
 
16
17
  Object.defineProperty(ObjectId.prototype, '_id', {
@@ -7,7 +7,7 @@
7
7
  const mongodb = require('mongodb');
8
8
  const ReadPref = mongodb.ReadPreference;
9
9
 
10
- /*!
10
+ /**
11
11
  * Converts arguments to ReadPrefs the driver
12
12
  * can understand.
13
13
  *
@@ -66,8 +66,10 @@ NativeCollection.prototype.onClose = function(force) {
66
66
 
67
67
  const syncCollectionMethods = { watch: true, find: true, aggregate: true };
68
68
 
69
- /*!
69
+ /**
70
70
  * Copy the collection methods and make them subject to queues
71
+ * @param {Number|String} I
72
+ * @api private
71
73
  */
72
74
 
73
75
  function iter(i) {
@@ -296,8 +298,10 @@ NativeCollection.prototype.$format = function(arg, color, shell) {
296
298
  return format(arg, false, color, shell);
297
299
  };
298
300
 
299
- /*!
301
+ /**
300
302
  * Debug print helper
303
+ * @param {Any} representation
304
+ * @api private
301
305
  */
302
306
 
303
307
  function inspectable(representation) {
@@ -8,7 +8,7 @@ const MongooseError = require('./');
8
8
 
9
9
 
10
10
  class MissingSchemaError extends MongooseError {
11
- /*!
11
+ /**
12
12
  * MissingSchema Error constructor.
13
13
  */
14
14
  constructor() {
package/lib/error/cast.js CHANGED
@@ -56,9 +56,10 @@ class CastError extends MongooseError {
56
56
  this.valueType = getValueType(value);
57
57
  }
58
58
 
59
- /*!
59
+ /**
60
60
  * ignore
61
61
  * @param {Readonly<CastError>} other
62
+ * @api private
62
63
  */
63
64
  copy(other) {
64
65
  this.messageFormat = other.messageFormat;
@@ -8,9 +8,10 @@
8
8
  const MongooseError = require('./');
9
9
 
10
10
  class DivergentArrayError extends MongooseError {
11
- /*!
11
+ /**
12
12
  * DivergentArrayError constructor.
13
13
  * @param {Array<String>} paths
14
+ * @api private
14
15
  */
15
16
  constructor(paths) {
16
17
  const msg = 'For your own good, using `document.save()` to update an array '
@@ -8,9 +8,10 @@
8
8
  const MongooseError = require('./');
9
9
 
10
10
  class MissingSchemaError extends MongooseError {
11
- /*!
11
+ /**
12
12
  * MissingSchema Error constructor.
13
13
  * @param {String} name
14
+ * @api private
14
15
  */
15
16
  constructor(name) {
16
17
  const msg = 'Schema hasn\'t been registered for model "' + name + '".\n'
@@ -8,8 +8,9 @@ const MongooseError = require('./');
8
8
  const util = require('util');
9
9
 
10
10
  class DocumentNotFoundError extends MongooseError {
11
- /*!
11
+ /**
12
12
  * OverwriteModel Error constructor.
13
+ * @api private
13
14
  */
14
15
  constructor(filter, model, numAffected, result) {
15
16
  let msg;
@@ -9,9 +9,10 @@ const MongooseError = require('./');
9
9
 
10
10
 
11
11
  class OverwriteModelError extends MongooseError {
12
- /*!
12
+ /**
13
13
  * OverwriteModel Error constructor.
14
14
  * @param {String} name
15
+ * @api private
15
16
  */
16
17
  constructor(name) {
17
18
  super('Cannot overwrite `' + name + '` model once compiled.');
@@ -41,15 +41,19 @@ class ValidationError extends MongooseError {
41
41
  return this.name + ': ' + _generateMessage(this);
42
42
  }
43
43
 
44
- /*!
44
+ /**
45
45
  * inspect helper
46
+ * @api private
46
47
  */
47
48
  inspect() {
48
49
  return Object.assign(new Error(this.message), this);
49
50
  }
50
51
 
51
- /*!
52
+ /**
52
53
  * add message
54
+ * @param {String} path
55
+ * @param {String|Error} error
56
+ * @api private
53
57
  */
54
58
  addError(path, error) {
55
59
  if (error instanceof ValidationError) {
@@ -68,16 +72,14 @@ class ValidationError extends MongooseError {
68
72
 
69
73
 
70
74
  if (util.inspect.custom) {
71
- /*!
72
- * Avoid Node deprecation warning DEP0079
73
- */
74
-
75
+ // Avoid Node deprecation warning DEP0079
75
76
  ValidationError.prototype[util.inspect.custom] = ValidationError.prototype.inspect;
76
77
  }
77
78
 
78
- /*!
79
+ /**
79
80
  * Helper for JSON.stringify
80
81
  * Ensure `name` and `message` show up in toJSON output re: gh-9847
82
+ * @api private
81
83
  */
82
84
  Object.defineProperty(ValidationError.prototype, 'toJSON', {
83
85
  enumerable: false,
@@ -31,16 +31,18 @@ class ValidatorError extends MongooseError {
31
31
  this.reason = properties.reason;
32
32
  }
33
33
 
34
- /*!
34
+ /**
35
35
  * toString helper
36
36
  * TODO remove? This defaults to `${this.name}: ${this.message}`
37
+ * @api private
37
38
  */
38
39
  toString() {
39
40
  return this.message;
40
41
  }
41
42
 
42
- /*!
43
+ /**
43
44
  * Ensure `name` and `message` show up in toJSON output re: gh-9296
45
+ * @api private
44
46
  */
45
47
 
46
48
  toJSON() {
@@ -53,9 +55,10 @@ Object.defineProperty(ValidatorError.prototype, 'name', {
53
55
  value: 'ValidatorError'
54
56
  });
55
57
 
56
- /*!
58
+ /**
57
59
  * The object used to define this validator. Not enumerable to hide
58
60
  * it from `require('util').inspect()` output re: gh-3925
61
+ * @api private
59
62
  */
60
63
 
61
64
  Object.defineProperty(ValidatorError.prototype, 'properties', {
@@ -67,8 +70,9 @@ Object.defineProperty(ValidatorError.prototype, 'properties', {
67
70
  // Exposed for testing
68
71
  ValidatorError.prototype.formatMessage = formatMessage;
69
72
 
70
- /*!
73
+ /**
71
74
  * Formats error messages
75
+ * @api private
72
76
  */
73
77
 
74
78
  function formatMessage(msg, properties) {
@@ -12,7 +12,7 @@ const trustedSymbol = require('./query/trusted').trustedSymbol;
12
12
  const utils = require('../utils');
13
13
 
14
14
 
15
- /*!
15
+ /**
16
16
  * Object clone with Mongoose natives support.
17
17
  *
18
18
  * If options.minimize is true, creates a minimal data object. Empty objects and undefined values will not be cloned. This makes the data payload sent to MongoDB as small as possible.
@@ -2,8 +2,9 @@
2
2
 
3
3
  const getDiscriminatorByValue = require('./getDiscriminatorByValue');
4
4
 
5
- /*!
5
+ /**
6
6
  * Find the correct constructor, taking into account discriminators
7
+ * @api private
7
8
  */
8
9
 
9
10
  module.exports = function getConstructor(Constructor, value) {
@@ -2,12 +2,13 @@
2
2
 
3
3
  const areDiscriminatorValuesEqual = require('./areDiscriminatorValuesEqual');
4
4
 
5
- /*!
6
- * returns discriminator by discriminatorMapping.value
7
- *
8
- * @param {Model} model
9
- * @param {string} value
10
- */
5
+ /**
6
+ * returns discriminator by discriminatorMapping.value
7
+ *
8
+ * @param {Object} discriminators
9
+ * @param {string} value
10
+ * @api private
11
+ */
11
12
 
12
13
  module.exports = function getDiscriminatorByValue(discriminators, value) {
13
14
  if (discriminators == null) {
@@ -2,12 +2,13 @@
2
2
 
3
3
  const areDiscriminatorValuesEqual = require('./areDiscriminatorValuesEqual');
4
4
 
5
- /*!
6
- * returns discriminator by discriminatorMapping.value
7
- *
8
- * @param {Schema} schema
9
- * @param {string} value
10
- */
5
+ /**
6
+ * returns discriminator by discriminatorMapping.value
7
+ *
8
+ * @param {Schema} schema
9
+ * @param {string} value
10
+ * @api private
11
+ */
11
12
 
12
13
  module.exports = function getSchemaDiscriminatorByValue(schema, value) {
13
14
  if (schema == null || schema.discriminators == null) {
@@ -24,8 +24,13 @@ const _isEmptyOptions = Object.freeze({
24
24
  transform: false
25
25
  });
26
26
 
27
- /*!
27
+ /**
28
28
  * Compiles schemas.
29
+ * @param {Object} tree
30
+ * @param {Any} proto
31
+ * @param {String} prefix
32
+ * @param {Object} options
33
+ * @api private
29
34
  */
30
35
 
31
36
  function compile(tree, proto, prefix, options) {
@@ -44,8 +49,15 @@ function compile(tree, proto, prefix, options) {
44
49
  }
45
50
  }
46
51
 
47
- /*!
52
+ /**
48
53
  * Defines the accessor named prop on the incoming prototype.
54
+ * @param {Object} options
55
+ * @param {String} options.prop
56
+ * @param {Boolean} options.subprops
57
+ * @param {Any} options.prototype
58
+ * @param {String} [options.prefix]
59
+ * @param {Object} options.options
60
+ * @api private
49
61
  */
50
62
 
51
63
  function defineKey({ prop, subprops, prototype, prefix, options }) {
@@ -3,9 +3,13 @@
3
3
  const get = require('../get');
4
4
  const getSchemaDiscriminatorByValue = require('../discriminator/getSchemaDiscriminatorByValue');
5
5
 
6
- /*!
6
+ /**
7
7
  * Like `schema.path()`, except with a document, because impossible to
8
8
  * determine path type without knowing the embedded discriminator key.
9
+ * @param {Document} doc
10
+ * @param {String} path
11
+ * @param {Object} [options]
12
+ * @api private
9
13
  */
10
14
 
11
15
  module.exports = function getEmbeddedDiscriminatorPath(doc, path, options) {
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
- /*!
3
+ /**
4
4
  * Simplified lodash.get to work around the annoying null quirk. See:
5
5
  * https://github.com/lodash/lodash/issues/3659
6
+ * @api private
6
7
  */
7
8
 
8
9
  module.exports = function get(obj, path, def) {
@@ -1,7 +1,8 @@
1
1
  'use strict';
2
2
 
3
- /*!
3
+ /**
4
4
  * If `val` is an object, returns constructor name, if possible. Otherwise returns undefined.
5
+ * @api private
5
6
  */
6
7
 
7
8
  module.exports = function getConstructorName(val) {
@@ -1,7 +1,8 @@
1
1
  'use strict';
2
2
 
3
- /*!
3
+ /**
4
4
  * Get the bson type, if it exists
5
+ * @api private
5
6
  */
6
7
 
7
8
  function isBsonType(obj, typename) {
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  const isMongooseArray = require('../types/array/isMongooseArray').isMongooseArray;
4
- /*!
4
+ /**
5
5
  * Returns if `v` is a mongoose object that has a `toObject()` method we can use.
6
6
  *
7
7
  * This is for compatibility with libs like Date.js which do foolish things to Natives.
8
8
  *
9
- * @param {any} v
9
+ * @param {Any} v
10
10
  * @api private
11
11
  */
12
12
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- /*!
3
+ /**
4
4
  * Determines if `arg` is an object.
5
5
  *
6
6
  * @param {Object|Array|String|Function|RegExp|any} arg
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- /*!
3
+ /**
4
4
  * Determines if `arg` is a flat object.
5
5
  *
6
6
  * @param {Object|Array|String|Function|RegExp|any} arg