From 34106aa2096728858a1aa71924553a14e8a4cded Mon Sep 17 00:00:00 2001 From: barisusakli Date: Sat, 27 Sep 2014 17:46:39 -0400 Subject: [PATCH] fix fields --- src/database/mongo/sorted.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/database/mongo/sorted.js b/src/database/mongo/sorted.js index 7c085cd48c..3714f5549d 100644 --- a/src/database/mongo/sorted.js +++ b/src/database/mongo/sorted.js @@ -104,7 +104,12 @@ module.exports = function(db, module) { if (!key) { return callback(); } - db.collection('objects').find({_key:key}, {fields: {_id: 0, value: 1, score: 1}}) + + var fields = {_id: 0, value: 1}; + if (withScores) { + fields['score'] = 1; + } + db.collection('objects').find({_key:key}, {fields: fields}) .limit(stop - start + 1) .skip(start) .sort({score: sort}) @@ -163,8 +168,7 @@ module.exports = function(db, module) { scoreQuery['$lte'] = max; } - var fields = {_id: 0}; - fields['value'] = 1; + var fields = {_id: 0, value: 1}; if (withScores) { fields['score'] = 1; }