File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -4726,6 +4726,25 @@ describe('Model', function() {
4726
4726
} ) ;
4727
4727
} ) ;
4728
4728
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
+
4729
4748
it ( 'insertMany() validation error with ordered true and rawResult true when all documents are invalid' , function ( done ) {
4730
4749
const schema = new Schema ( {
4731
4750
name : { type : String , required : true }
You can’t perform that action at this time.
0 commit comments