From e47b669add02cb753aeb70033cbebe873fca3109 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 30 Jul 2018 18:41:47 -0400 Subject: [PATCH] fix(populate): make error reported when no `localField` specified catchable Fix #6767 --- docs/source/api.js | 4 +--- lib/model.js | 2 +- lib/query.js | 2 ++ 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/api.js b/docs/source/api.js index f4807a8773e..0f4b60265c8 100644 --- a/docs/source/api.js +++ b/docs/source/api.js @@ -104,9 +104,7 @@ function parse() { } } - if (ctx.string.includes('Model')) { - console.log(ctx); - } + console.log(ctx); // Backwards compat if (typeof ctx.constructor === 'string') { diff --git a/lib/model.js b/lib/model.js index 6af12b84388..309d1047049 100644 --- a/lib/model.js +++ b/lib/model.js @@ -3946,7 +3946,7 @@ function getModelsMapForPopulate(model, docs, options) { } if (virtual && (!localField || !foreignField)) { - throw new Error('If you are populating a virtual, you must set the ' + + return new Error('If you are populating a virtual, you must set the ' + 'localField and foreignField options'); } diff --git a/lib/query.js b/lib/query.js index f78ef43b726..eb2efdd9e1b 100644 --- a/lib/query.js +++ b/lib/query.js @@ -1180,6 +1180,8 @@ Query.prototype.wtimeout = function wtimeout(ms) { * * Read more about how to use read concern [here](https://docs.mongodb.com/manual/reference/read-concern/). * + * @memberOf Query + * @method readConcern * @param {String} level one of the listed read concern level or their aliases * @see mongodb https://docs.mongodb.com/manual/reference/read-concern/ * @return {Query} this