From 754db14177fb1dcfc88f99d9600232e1b2b4112a Mon Sep 17 00:00:00 2001 From: Bruno Date: Sat, 18 Nov 2017 14:20:46 -0300 Subject: [PATCH 1/3] fix(model): allow virtual ref function to return arrays --- lib/model.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/model.js b/lib/model.js index ecf2ff52eee..000c1d2e80c 100644 --- a/lib/model.js +++ b/lib/model.js @@ -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 From 69f4ced7d9c9631a7637ba445224210af8e6e474 Mon Sep 17 00:00:00 2001 From: Bruno Date: Sat, 18 Nov 2017 14:30:09 -0300 Subject: [PATCH 2/3] fix trailing spaces --- lib/model.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/model.js b/lib/model.js index 000c1d2e80c..d159f13a3b7 100644 --- a/lib/model.js +++ b/lib/model.js @@ -3580,7 +3580,7 @@ function getModelsMapForPopulate(model, docs, options) { if (typeof ref === 'function') { ref = ref.call(doc, doc); } - + // When referencing nested arrays, the ref should be an Array // of modelNames. if (Array.isArray(ref)) { From 0b13451bb89d4d6a4be81447fcbcd1039da0c2cd Mon Sep 17 00:00:00 2001 From: Bruno Date: Sat, 18 Nov 2017 14:33:27 -0300 Subject: [PATCH 3/3] fix trailing spaces --- lib/model.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/model.js b/lib/model.js index d159f13a3b7..3405b990224 100644 --- a/lib/model.js +++ b/lib/model.js @@ -3581,7 +3581,7 @@ function getModelsMapForPopulate(model, docs, options) { ref = ref.call(doc, doc); } - // When referencing nested arrays, the ref should be an Array + // When referencing nested arrays, the ref should be an Array // of modelNames. if (Array.isArray(ref)) { modelNames = ref;