Update Node_modules

This commit is contained in:
2019-07-02 16:05:15 +02:00
parent 95a0ff3913
commit 9dab5e2dbc
3495 changed files with 39728 additions and 465154 deletions
+17 -3
View File
@@ -250,12 +250,26 @@ SchemaArray.prototype.cast = function(value, doc, init) {
if (!value.length && doc) {
const indexes = doc.schema.indexedPaths();
const arrayPath = this.path;
for (i = 0, l = indexes.length; i < l; ++i) {
const pathIndex = indexes[i][0][this.path];
const pathIndex = indexes[i][0][arrayPath];
if (pathIndex === '2dsphere' || pathIndex === '2d') {
return;
}
}
// Special case: if this index is on the parent of what looks like
// GeoJSON, skip setting the default to empty array re: #1668, #3233
const arrayGeojsonPath = this.path.endsWith('.coordinates') ?
this.path.substr(0, this.path.lastIndexOf('.')) : null;
if (arrayGeojsonPath != null) {
for (i = 0, l = indexes.length; i < l; ++i) {
const pathIndex = indexes[i][0][arrayGeojsonPath];
if (pathIndex === '2dsphere') {
return;
}
}
}
}
if (!(value && value.isMongooseArray)) {
@@ -417,7 +431,7 @@ function cast$elemMatch(val) {
for (let i = 0; i < numKeys; ++i) {
const key = keys[i];
const value = val[key];
if (key.indexOf('$') === 0 && value) {
if (key.startsWith('$') && value) {
val[key] = this.castForQuery(key, value);
}
}
@@ -474,11 +488,11 @@ handle.$gte =
handle.$lt =
handle.$lte =
handle.$ne =
handle.$nin =
handle.$regex = SchemaArray.prototype.castForQuery;
// `$in` is special because you can also include an empty array in the query
// like `$in: [1, []]`, see gh-5913
handle.$nin = SchemaType.prototype.$conditionalHandlers.$nin;
handle.$in = SchemaType.prototype.$conditionalHandlers.$in;
/*!
+3 -1
View File
@@ -7,6 +7,8 @@
const handleBitwiseOperator = require('./operators/bitwise');
const utils = require('../utils');
const populateModelSymbol = require('../helpers/symbols').populateModelSymbol;
const MongooseBuffer = require('../types/buffer');
const SchemaType = require('../schematype');
@@ -125,7 +127,7 @@ SchemaBuffer.prototype.cast = function(value, doc, init) {
const path = doc.$__fullPath(this.path);
const owner = doc.ownerDocument ? doc.ownerDocument() : doc;
const pop = owner.populated(path, true);
ret = new pop.options.model(value);
ret = new pop.options[populateModelSymbol](value);
ret.$__.wasPopulated = true;
return ret;
}
+3 -1
View File
@@ -10,6 +10,8 @@ const Decimal128Type = require('../types/decimal128');
const castDecimal128 = require('../cast/decimal128');
const utils = require('../utils');
const populateModelSymbol = require('../helpers/symbols').populateModelSymbol;
let Document;
/**
@@ -170,7 +172,7 @@ Decimal128.prototype.cast = function(value, doc, init) {
!doc.$__.populated[path].options ||
!doc.$__.populated[path].options.options ||
!doc.$__.populated[path].options.options.lean) {
ret = new pop.options.model(value);
ret = new pop.options[populateModelSymbol](value);
ret.$__.wasPopulated = true;
}
+14 -33
View File
@@ -11,7 +11,7 @@ const SchemaType = require('../schematype');
const discriminator = require('../helpers/model/discriminator');
const util = require('util');
const utils = require('../utils');
const getDiscriminatorByValue = require('../queryhelpers').getDiscriminatorByValue;
const getConstructor = require('../helpers/discriminator/getConstructor');
const arrayParentSymbol = require('../helpers/symbols').arrayParentSymbol;
const arrayPathSymbol = require('../helpers/symbols').arrayPathSymbol;
@@ -210,7 +210,7 @@ DocumentArray.prototype.doValidate = function(array, fn, scope, options) {
// If you set the array index directly, the doc might not yet be
// a full fledged mongoose subdoc, so make it into one.
if (!(doc instanceof Subdocument)) {
const Constructor = getConstructor(_this, array[i]);
const Constructor = getConstructor(_this.casterConstructor, array[i]);
doc = array[i] = new Constructor(doc, array, undefined, undefined, i);
}
@@ -258,7 +258,7 @@ DocumentArray.prototype.doValidateSync = function(array, scope) {
// If you set the array index directly, the doc might not yet be
// a full fledged mongoose subdoc, so make it into one.
if (!(doc instanceof Subdocument)) {
const Constructor = getConstructor(this, array[i]);
const Constructor = getConstructor(this.casterConstructor, array[i]);
doc = array[i] = new Constructor(doc, array, undefined, undefined, i);
}
@@ -297,7 +297,7 @@ DocumentArray.prototype.getDefault = function(scope) {
ret[arrayParentSymbol] = null;
for (let i = 0; i < ret.length; ++i) {
const Constructor = getConstructor(this, ret[i]);
const Constructor = getConstructor(this.casterConstructor, ret[i]);
ret[i] = new Constructor(ret[i], ret, undefined,
undefined, i);
}
@@ -353,12 +353,17 @@ DocumentArray.prototype.cast = function(value, doc, init, prev, options) {
continue;
}
const Constructor = getConstructor(this, value[i]);
const Constructor = getConstructor(this.casterConstructor, value[i]);
// Check if the document has a different schema (re gh-3701)
if ((value[i].$__) &&
!(value[i] instanceof Constructor)) {
value[i] = value[i].toObject({ transform: false, virtuals: false });
value[i] = value[i].toObject({
transform: false,
// Special case: if different model, but same schema, apply virtuals
// re: gh-7898
virtuals: value[i].schema === Constructor.schema
});
}
if (value[i] instanceof Subdocument) {
@@ -377,7 +382,7 @@ DocumentArray.prototype.cast = function(value, doc, init, prev, options) {
subdoc = new Constructor(null, value, true, selected, i);
value[i] = subdoc.init(value[i]);
} else {
if (prev && (subdoc = prev.id(value[i]._id))) {
if (prev && typeof prev.id === 'function') {
subdoc = prev.id(value[i]._id);
}
@@ -410,30 +415,6 @@ DocumentArray.prototype.cast = function(value, doc, init, prev, options) {
return value;
};
/*!
* Find the correct subdoc constructor, taking into account discriminators
*/
function getConstructor(docArray, subdoc) {
let Constructor = docArray.casterConstructor;
const schema = Constructor.schema;
const discriminatorKey = schema.options.discriminatorKey;
const discriminatorValue = subdoc[discriminatorKey];
if (Constructor.discriminators && typeof discriminatorValue === 'string') {
if (Constructor.discriminators[discriminatorValue]) {
Constructor = Constructor.discriminators[discriminatorValue];
} else {
const constructorByValue = getDiscriminatorByValue(Constructor,
discriminatorValue);
if (constructorByValue) {
Constructor = constructorByValue;
}
}
}
return Constructor;
}
/*!
* ignore
*/
@@ -483,12 +464,12 @@ function scopePaths(array, fields, init) {
while (i--) {
key = keys[i];
if (key.indexOf(path) === 0) {
if (key.startsWith(path)) {
sub = key.substring(path.length);
if (sub === '$') {
continue;
}
if (sub.indexOf('$.') === 0) {
if (sub.startsWith('$.')) {
sub = sub.substr(2);
}
hasKeys || (hasKeys = true);
+5 -43
View File
@@ -13,7 +13,7 @@ const castToNumber = require('./operators/helpers').castToNumber;
const discriminator = require('../helpers/model/discriminator');
const geospatial = require('./operators/geospatial');
const get = require('../helpers/get');
const getDiscriminatorByValue = require('../queryhelpers').getDiscriminatorByValue;
const getConstructor = require('../helpers/discriminator/getConstructor');
const internalToObjectOptions = require('../options').internalToObjectOptions;
let Subdocument;
@@ -149,20 +149,7 @@ Embedded.prototype.cast = function(val, doc, init, priorVal) {
throw new ObjectExpectedError(this.path, val);
}
let Constructor = this.caster;
const discriminatorKey = Constructor.schema.options.discriminatorKey;
if (val != null &&
Constructor.discriminators &&
typeof val[discriminatorKey] === 'string') {
if (Constructor.discriminators[val[discriminatorKey]]) {
Constructor = Constructor.discriminators[val[discriminatorKey]];
} else {
const constructorByValue = getDiscriminatorByValue(Constructor, val[discriminatorKey]);
if (constructorByValue) {
Constructor = constructorByValue;
}
}
}
const Constructor = getConstructor(this.caster, val);
let subdoc;
@@ -216,20 +203,7 @@ Embedded.prototype.castForQuery = function($conditional, val) {
val = this._applySetters(val);
}
let Constructor = this.caster;
const discriminatorKey = Constructor.schema.options.discriminatorKey;
if (val != null &&
Constructor.discriminators &&
typeof val[discriminatorKey] === 'string') {
if (Constructor.discriminators[val[discriminatorKey]]) {
Constructor = Constructor.discriminators[val[discriminatorKey]];
} else {
const constructorByValue = getDiscriminatorByValue(Constructor, val[discriminatorKey]);
if (constructorByValue) {
Constructor = constructorByValue;
}
}
}
const Constructor = getConstructor(this.caster, val);
try {
val = new Constructor(val);
@@ -250,20 +224,7 @@ Embedded.prototype.castForQuery = function($conditional, val) {
*/
Embedded.prototype.doValidate = function(value, fn, scope, options) {
let Constructor = this.caster;
const discriminatorKey = Constructor.schema.options.discriminatorKey;
if (value != null &&
Constructor.discriminators &&
typeof value[discriminatorKey] === 'string') {
if (Constructor.discriminators[value[discriminatorKey]]) {
Constructor = Constructor.discriminators[value[discriminatorKey]];
} else {
const constructorByValue = getDiscriminatorByValue(Constructor, value[discriminatorKey]);
if (constructorByValue) {
Constructor = constructorByValue;
}
}
}
const Constructor = getConstructor(this.caster, value);
if (options && options.skipSchemaValidators) {
if (!(value instanceof Constructor)) {
@@ -328,5 +289,6 @@ Embedded.prototype.clone = function() {
const options = Object.assign({}, this.options);
const schematype = new this.constructor(this.schema, this.path, options);
schematype.validators = this.validators.slice();
schematype.caster.discriminators = Object.assign({}, this.caster.discriminators);
return schematype;
};
+3 -1
View File
@@ -10,6 +10,8 @@ const castNumber = require('../cast/number');
const handleBitwiseOperator = require('./operators/bitwise');
const utils = require('../utils');
const populateModelSymbol = require('../helpers/symbols').populateModelSymbol;
const CastError = SchemaType.CastError;
let Document;
@@ -293,7 +295,7 @@ SchemaNumber.prototype.cast = function(value, doc, init) {
const path = doc.$__fullPath(this.path);
const owner = doc.ownerDocument ? doc.ownerDocument() : doc;
const pop = owner.populated(path, true);
const ret = new pop.options.model(value);
const ret = new pop.options[populateModelSymbol](value);
ret.$__.wasPopulated = true;
return ret;
}
+3 -1
View File
@@ -9,6 +9,8 @@ const SchemaType = require('../schematype');
const oid = require('../types/objectid');
const utils = require('../utils');
const populateModelSymbol = require('../helpers/symbols').populateModelSymbol;
const CastError = SchemaType.CastError;
let Document;
@@ -226,7 +228,7 @@ ObjectId.prototype.cast = function(value, doc, init) {
!doc.$__.populated[path].options ||
!doc.$__.populated[path].options.options ||
!doc.$__.populated[path].options.options.lean) {
ret = new pop.options.model(value);
ret = new pop.options[populateModelSymbol](value);
ret.$__.wasPopulated = true;
}
+4 -2
View File
@@ -10,6 +10,8 @@ const MongooseError = require('../error');
const castString = require('../cast/string');
const utils = require('../utils');
const populateModelSymbol = require('../helpers/symbols').populateModelSymbol;
let Document;
/**
@@ -537,7 +539,7 @@ SchemaString.prototype.cast = function(value, doc, init) {
const path = doc.$__fullPath(this.path);
const owner = doc.ownerDocument ? doc.ownerDocument() : doc;
const pop = owner.populated(path, true);
const ret = new pop.options.model(value);
const ret = new pop.options[populateModelSymbol](value);
ret.$__.wasPopulated = true;
return ret;
}
@@ -577,7 +579,7 @@ SchemaString.prototype.$conditionalHandlers =
$gte: handleSingle,
$lt: handleSingle,
$lte: handleSingle,
$options: handleSingle,
$options: String,
$regex: handleSingle,
$not: handleSingle
});