Skip to content

Commit

Permalink
fix(update): skip setting defaults for single embedded subdocs undern…
Browse files Browse the repository at this point in the history
…eath maps

Fix #7909
  • Loading branch information
vkarpov15 committed Jun 22, 2019
1 parent ef79737 commit 0314b02
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/helpers/setDefaultsOnInsert.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ module.exports = function(filter, schema, castedDoc, options) {
}

schema.eachPath(function(path, schemaType) {
if (schemaType.$isSingleNested) {
// Skip single nested paths if underneath a map
if (schemaType.$isSingleNested && !schemaType.path.endsWith('.$*')) {
// Only handle nested schemas 1-level deep to avoid infinite
// recursion re: https://github.com/mongodb-js/mongoose-autopopulate/issues/11
schemaType.schema.eachPath(function(_path, _schemaType) {
Expand Down

0 comments on commit 0314b02

Please sign in to comment.