File tree 1 file changed +33
-0
lines changed
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -8081,4 +8081,37 @@ describe('document', function() {
8081
8081
doc . init ( data ) ;
8082
8082
require ( 'util' ) . inspect ( doc . subdocs ) ;
8083
8083
} ) ;
8084
+
8085
+ it ( 'set() merge option with single nested (gh-8201)' , function ( ) {
8086
+ const AddressSchema = Schema ( {
8087
+ street : { type : String , required : true } ,
8088
+ city : { type : String , required : true }
8089
+ } ) ;
8090
+ const PersonSchema = Schema ( {
8091
+ name : { type : String , required : true } ,
8092
+ address : { type : AddressSchema , required : true }
8093
+ } ) ;
8094
+ const Person = db . model ( 'gh8201' , PersonSchema ) ;
8095
+
8096
+ return co ( function * ( ) {
8097
+ yield Person . create ( {
8098
+ name : 'John Smith' ,
8099
+ address : {
8100
+ street : 'Real Street' ,
8101
+ city : 'Somewhere'
8102
+ }
8103
+ } ) ;
8104
+
8105
+ const person = yield Person . findOne ( ) ;
8106
+ person . set ( {
8107
+ name : 'John Smythe' ,
8108
+ address : { street : 'Fake Street' } } ,
8109
+ undefined ,
8110
+ { merge : true }
8111
+ ) ;
8112
+
8113
+ assert . equal ( person . address . city , 'Somewhere' ) ;
8114
+ yield person . save ( ) ;
8115
+ } ) ;
8116
+ } ) ;
8084
8117
} ) ;
You can’t perform that action at this time.
0 commit comments