sortedSetCount fix for +inf/-inf

This commit is contained in:
barisusakli
2014-12-31 16:09:33 -05:00
parent 03ee524121
commit 0a534b20e3
2 changed files with 9 additions and 2 deletions

View File

@@ -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);
});
};