Skip to content

Commit

Permalink
fix(schema): handle nested objects with _id: false
Browse files Browse the repository at this point in the history
Fix #7524
  • Loading branch information
vkarpov15 committed Feb 24, 2019
1 parent a89d3cb commit 7c4b995
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,10 @@ Schema.prototype.add = function add(obj, prefix) {
return;
}

if (obj._id === false) {
// Special case: setting top-level `_id` to false should convert to disabling
// the `_id` option. This behavior never worked before 5.4.11 but numerous
// codebases use it (see gh-7516, gh-7512).
if (obj._id === false && prefix == null) {
delete obj._id;
this.options._id = false;
}
Expand Down

0 comments on commit 7c4b995

Please sign in to comment.