File tree Expand file tree Collapse file tree 4 files changed +46
-2
lines changed Expand file tree Collapse file tree 4 files changed +46
-2
lines changed Original file line number Diff line number Diff line change 1+ 5.1.8 / 2018-07-02
2+ ==================
3+ * fix: don't throw TypeError if calling save() after original save() failed with push() #6638 [ evanhenke] ( https://github.com/evanhenke )
4+ * fix(query): add explain() helper and don't hydrate explain output #6625
5+ * docs(query): fix ` setOptions() ` lists #6624
6+ * docs: add geojson docs #6607
7+ * fix: bump mongodb -> 3.0.11 to avoid cyclic dependency error with retryWrites #6109
8+
195.1.7 / 2018-06-26
210==================
311 * docs: add npm badge to readme #6623 [ VFedyk] ( https://github.com/VFedyk )
Original file line number Diff line number Diff line change @@ -248,7 +248,11 @@ MongooseDocumentArray.mixin = {
248248
249249 toObject : function ( options ) {
250250 return this . map ( function ( doc ) {
251- return doc && doc . toObject ( options ) || null ;
251+ try {
252+ return doc . toObject ( options ) ;
253+ } catch ( e ) {
254+ return doc || null ;
255+ }
252256 } ) ;
253257 } ,
254258
Original file line number Diff line number Diff line change 11{
22 "name" : " mongoose" ,
33 "description" : " Mongoose MongoDB ODM" ,
4- "version" : " 5.1.8-pre " ,
4+ "version" : " 5.1.8" ,
55 "author" : " Guillermo Rauch <guillermo@learnboost.com>" ,
66 "keywords" : [
77 " mongodb" ,
Original file line number Diff line number Diff line change @@ -3729,6 +3729,38 @@ describe('Model', function() {
37293729 done ( ) ;
37303730 } ) ;
37313731 } ) ;
3732+
3733+ it ( 'no TypeError when attempting to save more than once after using atomics' , function ( done ) {
3734+ const M = db . model ( 'M' , new Schema ( {
3735+ test : { type : 'string' , unique : true } ,
3736+ elements : [ {
3737+ el : { type : 'string' , required : true }
3738+ } ]
3739+ } ) ) ;
3740+ const a = new M ( {
3741+ test : 'a' ,
3742+ elements : [ { el : 'b' } ]
3743+ } ) ;
3744+ const b = new M ( {
3745+ test : 'b' ,
3746+ elements : [ { el : 'c' } ]
3747+ } ) ;
3748+ a . save ( function ( ) {
3749+ b . save ( function ( ) {
3750+ b . elements . push ( { el : 'd' } ) ;
3751+ b . test = 'a' ;
3752+ b . save ( function ( error , res ) {
3753+ assert . strictEqual ( ! error , false ) ;
3754+ assert . strictEqual ( res , undefined ) ;
3755+ b . save ( function ( error , res ) {
3756+ assert . strictEqual ( ! error , false ) ;
3757+ assert . strictEqual ( res , undefined ) ;
3758+ done ( ) ;
3759+ } ) ;
3760+ } ) ;
3761+ } ) ;
3762+ } ) ;
3763+ } ) ;
37323764 } ) ;
37333765
37343766
You can’t perform that action at this time.
0 commit comments