mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
sortedSetCount fix for +inf/-inf
This commit is contained in:
@@ -204,7 +204,14 @@ module.exports = function(db, module) {
|
||||
if (!key) {
|
||||
return callback();
|
||||
}
|
||||
db.collection('objects').count({_key: key, score: {$gte: min, $lte: max}}, function(err, count) {
|
||||
var scoreQuery = {};
|
||||
if (min !== '-inf') {
|
||||
scoreQuery.$gte = min;
|
||||
}
|
||||
if (max !== '+inf') {
|
||||
scoreQuery.$lte = max;
|
||||
}
|
||||
db.collection('objects').count({_key: key, score: scoreQuery}, function(err, count) {
|
||||
callback(err, count ? count : 0);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user