Skip to content

Commit

Permalink
Fixes #8331
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelrahmanHafez committed Nov 13, 2019
1 parent d9163f5 commit 6c1dcb2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/helpers/model/castBulkWrite.js
Expand Up @@ -34,6 +34,9 @@ module.exports = function castBulkWrite(model, op, options) {
op = op['updateOne'];
return (callback) => {
try {
if (!op['filter']) throw new Error('Must provide a filter object.');
if (!op['update']) throw new Error('Must provide an update object.');

op['filter'] = cast(model.schema, op['filter']);
op['update'] = castUpdate(model.schema, op['update'], {
strict: model.schema.options.strict,
Expand Down Expand Up @@ -61,6 +64,9 @@ module.exports = function castBulkWrite(model, op, options) {
op = op['updateMany'];
return (callback) => {
try {
if (!op['filter']) throw new Error('Must provide a filter object.');
if (!op['update']) throw new Error('Must provide an update object.');

op['filter'] = cast(model.schema, op['filter']);
op['update'] = castUpdate(model.schema, op['update'], {
strict: model.schema.options.strict,
Expand Down

0 comments on commit 6c1dcb2

Please sign in to comment.