Skip to content

Commit

Permalink
fix(populate): handle populating underneath document array when docum…
Browse files Browse the repository at this point in the history
…ent array property doesn't exist in db

Fix #10003
  • Loading branch information
vkarpov15 committed Apr 17, 2021
1 parent 95f8fe7 commit 937cb24
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/helpers/populate/assignVals.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ module.exports = function assignVals(o) {
// See gh-8342, gh-8455
const schematype = originalSchema._getSchema(curPath);
if (valueToSet == null && schematype != null && schematype.$isMongooseArray) {
return;
break;
}
cur[parts[j]] = {};
}
cur = cur[parts[j]];
// If the property in MongoDB is a primitive, we won't be able to populate
// the nested path, so skip it. See gh-7545
if (typeof cur !== 'object') {
return;
break;
}
}
if (docs[i].$__) {
Expand Down

0 comments on commit 937cb24

Please sign in to comment.