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.
- package/.mocharc.yml +2 -0
- package/lib/aggregate.js +2 -1
- package/lib/cast/boolean.js +1 -1
- package/lib/cast/number.js +1 -1
- package/lib/cast/string.js +1 -1
- package/lib/cast.js +3 -0
- package/lib/connection.js +9 -1
- package/lib/cursor/AggregationCursor.js +14 -3
- package/lib/cursor/QueryCursor.js +14 -3
- package/lib/document.js +27 -14
- package/lib/drivers/browser/objectid.js +2 -1
- package/lib/drivers/node-mongodb-native/ReadPreference.js +1 -1
- package/lib/drivers/node-mongodb-native/collection.js +6 -2
- package/lib/error/browserMissingSchema.js +1 -1
- package/lib/error/cast.js +2 -1
- package/lib/error/divergentArray.js +2 -1
- package/lib/error/missingSchema.js +2 -1
- package/lib/error/notFound.js +2 -1
- package/lib/error/overwriteModel.js +2 -1
- package/lib/error/validation.js +9 -7
- package/lib/error/validator.js +8 -4
- package/lib/helpers/clone.js +1 -1
- package/lib/helpers/discriminator/getConstructor.js +2 -1
- package/lib/helpers/discriminator/getDiscriminatorByValue.js +7 -6
- package/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +7 -6
- package/lib/helpers/document/compile.js +14 -2
- package/lib/helpers/document/getEmbeddedDiscriminatorPath.js +5 -1
- package/lib/helpers/get.js +2 -1
- package/lib/helpers/getConstructorName.js +2 -1
- package/lib/helpers/isBsonType.js +2 -1
- package/lib/helpers/isMongooseObject.js +2 -2
- package/lib/helpers/isObject.js +1 -1
- package/lib/helpers/isSimpleValidator.js +1 -1
- package/lib/helpers/model/applyHooks.js +3 -1
- package/lib/helpers/model/applyMethods.js +2 -1
- package/lib/helpers/model/applyStatics.js +2 -1
- package/lib/helpers/model/castBulkWrite.js +7 -2
- package/lib/helpers/model/discriminator.js +3 -1
- package/lib/helpers/pluralize.js +1 -1
- package/lib/helpers/populate/assignRawDocsToIdStructure.js +5 -3
- package/lib/helpers/populate/assignVals.js +14 -3
- package/lib/helpers/populate/createPopulateQueryFilter.js +8 -2
- package/lib/helpers/populate/getModelsMapForPopulate.js +3 -1
- package/lib/helpers/populate/getSchemaTypes.js +3 -1
- package/lib/helpers/populate/markArraySubdocsPopulated.js +5 -1
- package/lib/helpers/projection/hasIncludedChildren.js +4 -1
- package/lib/helpers/projection/isPathExcluded.js +3 -2
- package/lib/helpers/projection/isSubpath.js +2 -1
- package/lib/helpers/query/applyQueryMiddleware.js +3 -2
- package/lib/helpers/query/castUpdate.js +14 -8
- package/lib/helpers/query/completeMany.js +3 -2
- package/lib/helpers/query/getEmbeddedDiscriminatorPath.js +7 -1
- package/lib/helpers/query/wrapThunk.js +3 -1
- package/lib/helpers/schema/getIndexes.js +7 -2
- package/lib/helpers/schema/getPath.js +4 -3
- package/lib/helpers/schema/idGetter.js +2 -1
- package/lib/index.js +10 -2
- package/lib/model.js +60 -26
- package/lib/query.js +124 -29
- package/lib/queryhelpers.js +4 -4
- package/lib/schema/SubdocumentPath.js +1 -1
- package/lib/schema/array.js +1 -1
- package/lib/schema/date.js +2 -1
- package/lib/schema/documentarray.js +3 -2
- package/lib/schema/operators/helpers.js +2 -2
- package/lib/schema/operators/text.js +1 -1
- package/lib/schema.js +11 -3
- package/lib/schematype.js +17 -4
- package/lib/statemachine.js +13 -12
- package/lib/types/ArraySubdocument.js +13 -3
- package/lib/types/DocumentArray/methods/index.js +7 -3
- package/lib/types/array/methods/index.js +1 -0
- package/lib/types/map.js +3 -1
- package/lib/types/objectid.js +2 -2
- package/lib/types/subdocument.js +30 -8
- package/lib/utils.js +58 -31
- package/package.json +1 -1
- package/types/document.d.ts +1 -1
- package/types/middlewares.d.ts +1 -1
- package/types/models.d.ts +1 -1
package/.mocharc.yml
ADDED
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;
|
package/lib/cast/boolean.js
CHANGED
package/lib/cast/number.js
CHANGED
package/lib/cast/string.js
CHANGED
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
|
-
*
|
|
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(
|
|
4430
|
-
if (Array.isArray(
|
|
4431
|
-
|
|
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 (
|
|
4436
|
-
|
|
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;
|
|
@@ -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) {
|
package/lib/error/cast.js
CHANGED
|
@@ -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'
|
package/lib/error/notFound.js
CHANGED
|
@@ -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.');
|
package/lib/error/validation.js
CHANGED
|
@@ -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,
|
package/lib/error/validator.js
CHANGED
|
@@ -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) {
|
package/lib/helpers/clone.js
CHANGED
|
@@ -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,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
const areDiscriminatorValuesEqual = require('./areDiscriminatorValuesEqual');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
* returns discriminator by discriminatorMapping.value
|
|
7
|
-
*
|
|
8
|
-
* @param {
|
|
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) {
|
package/lib/helpers/get.js
CHANGED
|
@@ -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 {
|
|
9
|
+
* @param {Any} v
|
|
10
10
|
* @api private
|
|
11
11
|
*/
|
|
12
12
|
|
package/lib/helpers/isObject.js
CHANGED