diff --git a/lib/indexes.js b/lib/indexes.js index bb6119b..09952fb 100755 --- a/lib/indexes.js +++ b/lib/indexes.js @@ -236,14 +236,12 @@ Index.prototype.revertUpdate = function (oldDoc, newDoc) { * @return {Array of documents} */ Index.prototype.getMatching = function (value) { - var _res, res - , self = this; + var self = this; if (!util.isArray(value)) { - res = self.tree.search(value); + return self.tree.search(value); } else { - _res = {}; - res = []; + var _res = {}, res = []; value.forEach(function (v) { self.getMatching(v).forEach(function (doc) { @@ -254,8 +252,9 @@ Index.prototype.getMatching = function (value) { Object.keys(_res).forEach(function (_id) { res.push(_res[_id]); }); + + return res; } - return res; };