Skip to content

Node.js based forum software built for the modern web

query change

barisusakli8b4c61241f91
diff --git a/src/database/mongo/sorted.js b/src/database/mongo/sorted.js
index 96015b8f97..8813d77b36 100644
--- a/src/database/mongo/sorted.js
+++ b/src/database/mongo/sorted.js
@@ -72,7 +72,15 @@ module.exports = function(db, module) {
count = 0;
}
- db.collection('objects').find({_key:key, score: {$gte:min, $lte:max}}, {fields:{value:1}})
+ var scoreQuery = {};
+ if (min !== -Infinity) {
+ scoreQuery['$gte'] = min;
+ }
+ if (max !== Infinity) {
+ scoreQuery['$lte'] = max;
+ }
+
+ db.collection('objects').find({_key:key, score: scoreQuery}, {fields:{value:1}})
.limit(count)
.skip(start)
.sort({score: sort})