diff --git a/lib/model.js b/lib/model.js index 62a4b014837..b322ed23653 100644 --- a/lib/model.js +++ b/lib/model.js @@ -3410,7 +3410,7 @@ Model.bulkWrite = async function bulkWrite(ops, options) { results[validOpIndexes[i]] = null; } if (validationErrors.length > 0) { - if ('throwOnValidationError' in options && options.throwOnValidationError) { + if (options.throwOnValidationError) { return reject(new MongooseBulkWriteError( validationErrors, results, diff --git a/test/model.test.js b/test/model.test.js index 32aa31b027e..d448edae8fc 100644 --- a/test/model.test.js +++ b/test/model.test.js @@ -6237,6 +6237,9 @@ describe('Model', function() { assert.equal(err.validationErrors[0].errors['age'].name, 'CastError'); assert.ok(err.results[2] instanceof Error); assert.equal(err.results[2].errors['age'].name, 'CastError'); + + const docs = await User.find(); + assert.deepStrictEqual(docs.map(doc => doc.age), [12, 12]); }); it('returns writeResult on success', async() => {