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
+12 -2
View File
@@ -1,5 +1,6 @@
'use strict';
const middlewareFunctions = require('../query/applyQueryMiddleware').middlewareFunctions;
const utils = require('../../utils');
module.exports = function applyStaticHooks(model, hooks, statics) {
@@ -8,7 +9,16 @@ module.exports = function applyStaticHooks(model, hooks, statics) {
numCallbackParams: 1
};
hooks = hooks.filter(hook => hook.model !== false);
hooks = hooks.filter(hook => {
// If the custom static overwrites an existing query middleware, don't apply
// middleware to it by default. This avoids a potential backwards breaking
// change with plugins like `mongoose-delete` that use statics to overwrite
// built-in Mongoose functions.
if (middlewareFunctions.indexOf(hook.name) !== -1) {
return !!hook.model;
}
return hook.model !== false;
});
model.$__insertMany = hooks.createWrapper('insertMany',
model.$__insertMany, model, kareemOptions);
@@ -58,4 +68,4 @@ module.exports = function applyStaticHooks(model, hooks, statics) {
};
}
}
};
};
+26 -10
View File
@@ -38,15 +38,23 @@ module.exports = function discriminator(model, name, schema, tiedValue, applyPlu
const key = model.schema.options.discriminatorKey;
const baseSchemaAddition = {};
baseSchemaAddition[key] = {
default: void 0,
select: true,
$skipDiscriminatorCheck: true
};
baseSchemaAddition[key][model.schema.options.typeKey] = String;
model.schema.add(baseSchemaAddition);
defineKey(key, null, model.prototype, null, [key], model.schema.options);
const existingPath = model.schema.path(key);
if (existingPath != null) {
if (!utils.hasUserDefinedProperty(existingPath.options, 'select')) {
existingPath.options.select = true;
}
existingPath.options.$skipDiscriminatorCheck = true;
} else {
const baseSchemaAddition = {};
baseSchemaAddition[key] = {
default: void 0,
select: true,
$skipDiscriminatorCheck: true
};
baseSchemaAddition[key][model.schema.options.typeKey] = String;
model.schema.add(baseSchemaAddition);
defineKey(key, null, model.prototype, null, [key], model.schema.options);
}
if (schema.path(key) && schema.path(key).options.$skipDiscriminatorCheck !== true) {
throw new Error('Discriminator "' + name +
@@ -61,6 +69,7 @@ module.exports = function discriminator(model, name, schema, tiedValue, applyPlu
function merge(schema, baseSchema) {
// Retain original schema before merging base schema
schema._originalSchema = schema.clone();
schema._baseSchema = baseSchema;
if (baseSchema.paths._id &&
baseSchema.paths._id.options &&
!baseSchema.paths._id.options.auto) {
@@ -94,6 +103,11 @@ module.exports = function discriminator(model, name, schema, tiedValue, applyPlu
delete schema.paths[conflictingPaths[i]];
}
// Rebuild schema models because schemas may have been merged re: #7884
schema.childSchemas.forEach(obj => {
obj.model.prototype.$__setSchema(obj.schema);
});
const obj = {};
obj[key] = {
default: value,
@@ -106,7 +120,9 @@ module.exports = function discriminator(model, name, schema, tiedValue, applyPlu
},
$skipDiscriminatorCheck: true
};
obj[key][schema.options.typeKey] = String;
obj[key][schema.options.typeKey] = existingPath ?
existingPath.instance :
String;
schema.add(obj);
schema.discriminatorMapping = {key: key, value: value, isRoot: false};