File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -3245,4 +3245,26 @@ describe('model: updateOne: ', function() {
3245
3245
assert . ok ( doc . child . updatedAt . valueOf ( ) >= now ) ;
3246
3246
} ) ;
3247
3247
} ) ;
3248
+
3249
+ it ( 'supports discriminators if key is specified in conditions (gh-7843)' , function ( ) {
3250
+ const testSchema = new mongoose . Schema ( {
3251
+ title : { type : String , required : true } ,
3252
+ kind : { type : String , required : true }
3253
+ } , { discriminatorKey : 'kind' } ) ;
3254
+
3255
+ const Test = db . model ( 'gh7843' , testSchema ) ;
3256
+
3257
+ const testSchemaChild = new mongoose . Schema ( {
3258
+ label : String
3259
+ } ) ;
3260
+
3261
+ const TestChild = Test . discriminator ( 'gh7843_child' , testSchemaChild , 'testchild' ) ;
3262
+
3263
+ const filter = { label : 'bar' , kind : 'testchild' } ;
3264
+ const update = { label : 'updated' } ;
3265
+ return Test . create ( { title : 'foo' , kind : 'testchild' , label : 'bar' } ) .
3266
+ then ( ( ) => Test . updateOne ( filter , update ) ) .
3267
+ then ( ( ) => Test . collection . findOne ( ) ) .
3268
+ then ( doc => assert . equal ( doc . label , 'updated' ) ) ;
3269
+ } ) ;
3248
3270
} ) ;
You can’t perform that action at this time.
0 commit comments