Skip to content

Commit

Permalink
fix(populate): handle using count option with document arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Aug 3, 2019
1 parent 4ebbcf2 commit dc2e87c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/helpers/populate/assignVals.js
Expand Up @@ -118,6 +118,11 @@ module.exports = function assignVals(o) {

function numDocs(v) {
if (Array.isArray(v)) {
// If setting underneath an array of populated subdocs, we may have an
// array of arrays. See gh-7573
if (v.some(el => Array.isArray(el))) {
return v.map(el => numDocs(el));
}
return v.length;
}
return v == null ? 0 : 1;
Expand Down

0 comments on commit dc2e87c

Please sign in to comment.