File tree Expand file tree Collapse file tree 3 files changed +18
-0
lines changed Expand file tree Collapse file tree 3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -197,6 +197,10 @@ exports.default = function (schema, opts) {
197
197
return postUpdateOne . call ( this , { } , next ) ;
198
198
}
199
199
200
+ if ( this . options . new && this . options . rawResult ) {
201
+ doc = doc . value ;
202
+ }
203
+
200
204
doc . _original = this . _original ;
201
205
createPatch ( doc , this . options ) . then ( function ( ) {
202
206
return next ( ) ;
Original file line number Diff line number Diff line change @@ -335,6 +335,10 @@ export default function (schema, opts) {
335
335
return postUpdateOne . call ( this , { } , next )
336
336
}
337
337
338
+ if ( this . options . new && this . options . rawResult ) {
339
+ doc = doc . value
340
+ }
341
+
338
342
doc . _original = this . _original
339
343
createPatch ( doc , this . options )
340
344
. then ( ( ) => next ( ) )
Original file line number Diff line number Diff line change @@ -371,6 +371,16 @@ describe('mongoose-patch-history', () => {
371
371
} )
372
372
. catch ( done )
373
373
} )
374
+
375
+ it ( 'should work with options { new:true, rawResult:true }' , ( done ) => {
376
+ Post . findOneAndUpdate (
377
+ { title : 'findOneAndUpdate2' } ,
378
+ { title : 'findOneAndUpdate1' } ,
379
+ { new : true , rawResult : true }
380
+ )
381
+ . then ( ( ) => done ( ) )
382
+ . catch ( done )
383
+ } )
374
384
} )
375
385
376
386
describe ( 'updating a document via updateOne()' , ( ) => {
You can’t perform that action at this time.
0 commit comments