Skip to content

Commit

Permalink
fix(populate): clean up issues with #5124 that pop up when a conventi…
Browse files Browse the repository at this point in the history
…onal populate is nested under a virtual populate like #8432
  • Loading branch information
vkarpov15 committed Jun 16, 2020
1 parent 1f20d1c commit 5535fd3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/helpers/populate/getModelsMapForPopulate.js
Expand Up @@ -294,7 +294,9 @@ function _virtualPopulate(model, docs, options, _virtualRes) {
let justOne = null;
if ('justOne' in options && options.justOne !== void 0) {
justOne = options.justOne;
} else if (virtual.options.refPath) {
}

if (virtual.options.refPath) {
const normalizedRefPath =
normalizeRefPath(virtual.options.refPath, doc, options.path);
justOne = !!virtual.options.justOne;
Expand Down
3 changes: 3 additions & 0 deletions lib/model.js
Expand Up @@ -4363,6 +4363,9 @@ function populate(model, docs, options, callback) {
}

if (!hasOne) {
if (modelsMap.length > 0) {
return callback();
}
// If no models to populate but we have a nested populate,
// keep trying, re: gh-8946
if (options.populate != null) {
Expand Down

0 comments on commit 5535fd3

Please sign in to comment.