mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-06-20 18:20:28 +02:00
query change
This commit is contained in:
@@ -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})
|
||||
|
||||
Reference in New Issue
Block a user