File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -913,6 +913,35 @@ describe('document', function() {
913913 } ) ;
914914 } ) ;
915915 } ) ;
916+
917+ it ( 'populate on nested path (gh-5703)' , function ( ) {
918+ var toySchema = new mongoose . Schema ( { color : String } ) ;
919+ var Toy = db . model ( 'gh5703' , toySchema ) ;
920+
921+ var childSchema = new mongoose . Schema ( {
922+ name : String ,
923+ values : {
924+ toy : { type : mongoose . Schema . Types . ObjectId , ref : 'gh5703' }
925+ }
926+ } ) ;
927+ var Child = db . model ( 'gh5703_0' , childSchema ) ;
928+
929+ return Toy . create ( { color : 'blue' } ) .
930+ then ( function ( toy ) {
931+ return Child . create ( { values : { toy : toy . _id } } ) ;
932+ } ) .
933+ then ( function ( child ) {
934+ return Child . findById ( child . _id ) ;
935+ } ) .
936+ then ( function ( child ) {
937+ return child . values . populate ( 'toy' ) . execPopulate ( ) . then ( function ( ) {
938+ return child ;
939+ } ) ;
940+ } ) .
941+ then ( function ( child ) {
942+ assert . equal ( child . values . toy . color , 'blue' ) ;
943+ } ) ;
944+ } ) ;
916945 } ) ;
917946
918947 describe ( '#update' , function ( ) {
You can’t perform that action at this time.
0 commit comments