Skip to content

Commit

Permalink
refactor(populate): only call assign() after all model queries for a …
Browse files Browse the repository at this point in the history
…path are called re: #3812
  • Loading branch information
vkarpov15 committed Sep 6, 2019
1 parent 39566f1 commit eb75b54
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -4195,8 +4195,8 @@ function populate(model, docs, options, callback) {
return callback(err, null);
}
vals = vals.concat(valsFromDb);
_assign(model, vals, mod, assignmentOpts);
if (--_remaining === 0) {
_assign(model, vals, mod, assignmentOpts);
callback();
}
}]);
Expand Down
2 changes: 1 addition & 1 deletion test/model.populate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7478,7 +7478,7 @@ describe('model: populate:', function() {

const eventSchema = new Schema({
message: String
},{ discriminatorKey: 'kind' });
}, { discriminatorKey: 'kind' });

const batchSchema = new Schema({
events: [eventSchema]
Expand Down

0 comments on commit eb75b54

Please sign in to comment.