Skip to content

Commit

Permalink
fix(model): allow virtual ref function to return arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
brunohcastro committed Nov 18, 2017
1 parent 4348fa1 commit 754db14
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -3580,7 +3580,15 @@ function getModelsMapForPopulate(model, docs, options) {
if (typeof ref === 'function') {
ref = ref.call(doc, doc);
}
modelNames = [ref];

// When referencing nested arrays, the ref should be an Array
// of modelNames.
if (Array.isArray(ref)) {
modelNames = ref;
} else {
modelNames = [ref];
}

isVirtual = true;
} else {
// We may have a discriminator, in which case we don't want to
Expand Down

0 comments on commit 754db14

Please sign in to comment.