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
+15
View File
@@ -0,0 +1,15 @@
'use strict';
const utils = require('../../utils');
module.exports = function applyGlobalMaxTimeMS(options, model) {
if (utils.hasUserDefinedProperty(options, 'maxTimeMS')) {
return;
}
if (utils.hasUserDefinedProperty(model.db.options, 'maxTimeMS')) {
options.maxTimeMS = model.db.options.maxTimeMS;
} else if (utils.hasUserDefinedProperty(model.base.options, 'maxTimeMS')) {
options.maxTimeMS = model.base.options.maxTimeMS;
}
};
+3 -3
View File
@@ -3,7 +3,7 @@
module.exports = function castFilterPath(query, schematype, val) {
const ctx = query;
const any$conditionals = Object.keys(val).some(function(k) {
return k.charAt(0) === '$' && k !== '$id' && k !== '$ref';
return k.startsWith('$') && k !== '$id' && k !== '$ref';
});
if (!any$conditionals) {
@@ -24,7 +24,7 @@ module.exports = function castFilterPath(query, schematype, val) {
if ($cond === '$not') {
if (nested && schematype && !schematype.caster) {
const _keys = Object.keys(nested);
if (_keys.length && _keys[0].charAt(0) === '$') {
if (_keys.length && _keys[0].startsWith('$')) {
for (const key in nested) {
nested[key] = schematype.castForQueryWrapper({
$conditional: key,
@@ -52,4 +52,4 @@ module.exports = function castFilterPath(query, schematype, val) {
}
return val;
};
};
+19 -2
View File
@@ -5,6 +5,7 @@ const StrictModeError = require('../../error/strict');
const ValidationError = require('../../error/validation');
const castNumber = require('../../cast/number');
const getEmbeddedDiscriminatorPath = require('./getEmbeddedDiscriminatorPath');
const handleImmutable = require('./handleImmutable');
const utils = require('../../utils');
/*!
@@ -70,7 +71,7 @@ module.exports = function castUpdate(schema, obj, options, context, filter) {
while (i--) {
const op = ops[i];
val = ret[op];
hasDollarKey = hasDollarKey || op.charAt(0) === '$';
hasDollarKey = hasDollarKey || op.startsWith('$');
if (val &&
typeof val === 'object' &&
@@ -90,6 +91,10 @@ module.exports = function castUpdate(schema, obj, options, context, filter) {
+ 'Expected an object, received ' + typeof val;
throw new Error(msg);
}
if (op.startsWith('$') && Object.keys(val).length === 0) {
delete ret[op];
}
}
return hasKeys && ret;
@@ -137,6 +142,11 @@ function walkUpdatePath(schema, obj, op, options, context, filter, pref) {
if (val && val.constructor.name === 'Object') {
// watch for embedded doc schemas
schematype = schema._getSchema(prefix + key);
if (handleImmutable(schematype, strict, obj, key, prefix + key)) {
continue;
}
if (schematype && schematype.caster && op in castOps) {
// embedded doc schema
if ('$each' in val) {
@@ -218,6 +228,13 @@ function walkUpdatePath(schema, obj, op, options, context, filter, pref) {
const checkPath = (key === '$each' || key === '$or' || key === '$and' || key === '$in') ?
pref : prefix + key;
schematype = schema._getSchema(checkPath);
// You can use `$setOnInsert` with immutable keys
if (op !== '$setOnInsert' &&
handleImmutable(schematype, strict, obj, key, prefix + key)) {
continue;
}
let pathDetails = schema._getPathType(checkPath);
// If no schema type, check for embedded discriminators
@@ -386,7 +403,7 @@ function castUpdateVal(schema, val, op, $conditional, context, path) {
++arrayDepth;
}
let tmp = schema.cast(Array.isArray(val) ? val : [val]);
let tmp = schema.applySetters(Array.isArray(val) ? val : [val], context);
for (let i = 0; i < additionalNesting; ++i) {
tmp = tmp[0];
+18
View File
@@ -0,0 +1,18 @@
'use strict';
const StrictModeError = require('../../error/strict');
module.exports = function handleImmutable(schematype, strict, obj, key, fullPath) {
if (schematype == null || !schematype.options.immutable) {
return false;
}
if (strict === false) {
return false;
}
if (strict === 'throw') {
throw new StrictModeError(null,
`Field ${fullPath} is immutable and strict = 'throw'`);
}
delete obj[key];
return true;
};
+1 -1
View File
@@ -8,7 +8,7 @@ module.exports = function(obj) {
const keys = Object.keys(obj);
const len = keys.length;
for (let i = 0; i < len; ++i) {
if (keys[i].charAt(0) === '$') {
if (keys[i].startsWith('$')) {
return true;
}
}