Skip to content

Commit b2da840

Browse files
committedDec 10, 2020
test(model): repro #9677
1 parent dd348b1 commit b2da840

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
 

‎test/model.test.js

+19
Original file line numberDiff line numberDiff line change
@@ -4726,6 +4726,25 @@ describe('Model', function() {
47264726
});
47274727
});
47284728

4729+
it('insertMany() sets `isNew` for inserted documents with `ordered = false` (gh-9677)', function() {
4730+
const schema = new Schema({
4731+
title: { type: String, required: true, unique: true }
4732+
});
4733+
const Movie = db.model('Movie', schema);
4734+
4735+
const arr = [{ title: 'The Phantom Menace' }, { title: 'The Phantom Menace' }];
4736+
const opts = { ordered: false };
4737+
return co(function*() {
4738+
yield Movie.init();
4739+
const err = yield Movie.insertMany(arr, opts).then(() => err, err => err);
4740+
assert.ok(err);
4741+
assert.ok(err.insertedDocs);
4742+
4743+
assert.equal(err.insertedDocs.length, 1);
4744+
assert.strictEqual(err.insertedDocs[0].isNew, false);
4745+
});
4746+
});
4747+
47294748
it('insertMany() validation error with ordered true and rawResult true when all documents are invalid', function(done) {
47304749
const schema = new Schema({
47314750
name: { type: String, required: true }

0 commit comments

Comments
 (0)
Please sign in to comment.