Skip to content

Commit f94affd

Browse files
committed
Update curPath for nested path
1 parent 72b4094 commit f94affd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/helpers/populate/assignVals.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ module.exports = function assignVals(o) {
144144

145145
const parts = _path.split('.');
146146
let cur = docs[i];
147-
const curPath = parts[0];
147+
let curPath = parts[0];
148148
for (let j = 0; j < parts.length - 1; ++j) {
149149
// If we get to an array with a dotted path, like `arr.foo`, don't set
150150
// `foo` on the array.
@@ -167,6 +167,7 @@ module.exports = function assignVals(o) {
167167
cur[parts[j]] = {};
168168
}
169169
cur = cur[parts[j]];
170+
curPath += parts[j + 1] ? `.${parts[j + 1]}` : '';
170171
// If the property in MongoDB is a primitive, we won't be able to populate
171172
// the nested path, so skip it. See gh-7545
172173
if (typeof cur !== 'object') {

0 commit comments

Comments
 (0)