File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -1623,4 +1623,29 @@ describe('model: update:', function() {
16231623
16241624 db . close ( done ) ;
16251625 } ) ;
1626+
1627+ it ( 'middleware update with exec (gh-3549)' , function ( done ) {
1628+ var db = start ( ) ;
1629+
1630+ var Schema = mongoose . Schema ( { name : String } ) ;
1631+
1632+ Schema . pre ( 'update' , function ( next ) {
1633+ this . update ( { name : 'Val' } ) ;
1634+ next ( ) ;
1635+ } ) ;
1636+
1637+ var Model = db . model ( 'gh3549' , Schema ) ;
1638+
1639+ Model . create ( { } , function ( error , doc ) {
1640+ assert . ifError ( error ) ;
1641+ Model . update ( { _id : doc . _id } , { name : 'test' } ) . exec ( function ( error ) {
1642+ assert . ifError ( error ) ;
1643+ Model . findOne ( { _id : doc . _id } , function ( error , doc ) {
1644+ assert . ifError ( error ) ;
1645+ assert . equal ( doc . name , 'Val' ) ;
1646+ db . close ( done ) ;
1647+ } ) ;
1648+ } ) ;
1649+ } ) ;
1650+ } ) ;
16261651} ) ;
You can’t perform that action at this time.
0 commit comments