Changes
This commit is contained in:
23
node_modules/mongoose/lib/helpers/model/castBulkWrite.js
generated
vendored
23
node_modules/mongoose/lib/helpers/model/castBulkWrite.js
generated
vendored
@@ -37,8 +37,12 @@ module.exports = function castBulkWrite(originalModel, op, options) {
|
||||
} else if (op['updateOne']) {
|
||||
return (callback) => {
|
||||
try {
|
||||
if (!op['updateOne']['filter']) throw new Error('Must provide a filter object.');
|
||||
if (!op['updateOne']['update']) throw new Error('Must provide an update object.');
|
||||
if (!op['updateOne']['filter']) {
|
||||
throw new Error('Must provide a filter object.');
|
||||
}
|
||||
if (!op['updateOne']['update']) {
|
||||
throw new Error('Must provide an update object.');
|
||||
}
|
||||
|
||||
const model = decideModelByObject(originalModel, op['updateOne']['filter']);
|
||||
const schema = model.schema;
|
||||
@@ -54,7 +58,6 @@ module.exports = function castBulkWrite(originalModel, op, options) {
|
||||
|
||||
applyTimestampsToChildren(now, op['updateOne']['update'], model.schema);
|
||||
|
||||
|
||||
if (op['updateOne'].setDefaultsOnInsert) {
|
||||
setDefaultsOnInsert(op['updateOne']['filter'], model.schema, op['updateOne']['update'], {
|
||||
setDefaultsOnInsert: true,
|
||||
@@ -71,8 +74,7 @@ module.exports = function castBulkWrite(originalModel, op, options) {
|
||||
strict: strict,
|
||||
overwrite: false,
|
||||
upsert: op['updateOne'].upsert
|
||||
});
|
||||
|
||||
}, model, op['updateOne']['filter']);
|
||||
} catch (error) {
|
||||
return callback(error, null);
|
||||
}
|
||||
@@ -82,8 +84,12 @@ module.exports = function castBulkWrite(originalModel, op, options) {
|
||||
} else if (op['updateMany']) {
|
||||
return (callback) => {
|
||||
try {
|
||||
if (!op['updateMany']['filter']) throw new Error('Must provide a filter object.');
|
||||
if (!op['updateMany']['update']) throw new Error('Must provide an update object.');
|
||||
if (!op['updateMany']['filter']) {
|
||||
throw new Error('Must provide a filter object.');
|
||||
}
|
||||
if (!op['updateMany']['update']) {
|
||||
throw new Error('Must provide an update object.');
|
||||
}
|
||||
|
||||
const model = decideModelByObject(originalModel, op['updateMany']['filter']);
|
||||
const schema = model.schema;
|
||||
@@ -115,7 +121,7 @@ module.exports = function castBulkWrite(originalModel, op, options) {
|
||||
strict: strict,
|
||||
overwrite: false,
|
||||
upsert: op['updateMany'].upsert
|
||||
});
|
||||
}, model, op['updateMany']['filter']);
|
||||
|
||||
} catch (error) {
|
||||
return callback(error, null);
|
||||
@@ -153,6 +159,7 @@ module.exports = function castBulkWrite(originalModel, op, options) {
|
||||
if (error) {
|
||||
return callback(error, null);
|
||||
}
|
||||
op['replaceOne']['replacement'] = op['replaceOne']['replacement'].toBSON();
|
||||
callback(null);
|
||||
});
|
||||
};
|
||||
|
||||
12
node_modules/mongoose/lib/helpers/model/discriminator.js
generated
vendored
12
node_modules/mongoose/lib/helpers/model/discriminator.js
generated
vendored
@@ -149,11 +149,17 @@ module.exports = function discriminator(model, name, schema, tiedValue, applyPlu
|
||||
|
||||
for (const _key of keys) {
|
||||
if (!CUSTOMIZABLE_DISCRIMINATOR_OPTIONS[_key]) {
|
||||
// Special case: compiling a model sets `pluralization = true` by default. Avoid throwing an error
|
||||
// for that case. See gh-9238
|
||||
if (_key === 'pluralization' && schema.options[_key] == true && baseSchema.options[_key] == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!utils.deepEqual(schema.options[_key], baseSchema.options[_key])) {
|
||||
throw new Error('Can\'t customize discriminator option ' + _key +
|
||||
' (can only modify ' +
|
||||
Object.keys(CUSTOMIZABLE_DISCRIMINATOR_OPTIONS).join(', ') +
|
||||
')');
|
||||
' (can only modify ' +
|
||||
Object.keys(CUSTOMIZABLE_DISCRIMINATOR_OPTIONS).join(', ') +
|
||||
')');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user