Skip to content

Commit 0314b02

Browse files
committed
fix(update): skip setting defaults for single embedded subdocs underneath maps
Fix #7909
1 parent ef79737 commit 0314b02

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lib/helpers/setDefaultsOnInsert.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ module.exports = function(filter, schema, castedDoc, options) {
6969
}
7070

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

0 commit comments

Comments
 (0)