Skip to content

Commit

Permalink
fix(map): avoid infinite recursion when update overwrites a map
Browse files Browse the repository at this point in the history
Fix #6750
  • Loading branch information
vkarpov15 committed Jul 26, 2018
1 parent dec8da6 commit 629d2d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/types/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ class MongooseMap extends Map {
return new Map(this);
}

toObject() {
return new Map(this);
}

toJSON() {
let ret = {};
const keys = this.keys();
Expand Down
5 changes: 4 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,10 @@ exports.isMongooseObject = function(v) {
return false;
}

return v.$__ != null || v.isMongooseArray || v.isMongooseBuffer;
return v.$__ != null || // Document
v.isMongooseArray || // Array or Document Array
v.isMongooseBuffer || // Buffer
v.$isMongooseMap; // Map
};
var isMongooseObject = exports.isMongooseObject;

Expand Down

0 comments on commit 629d2d3

Please sign in to comment.