Skip to content

Node.js based forum software built for the modern web

fix fields

barisusakli34106aa20967
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;
}