From fe3417538c99a4cba96f28e7ebea76ac29e0f4e0 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Wed, 31 Aug 2016 21:22:28 +0300 Subject: [PATCH] fix getSortedSetRange() if start>0 and stop is -1 --- src/database/mongo/sorted.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/database/mongo/sorted.js b/src/database/mongo/sorted.js index 5cc06eab42..33e6d4e79b 100644 --- a/src/database/mongo/sorted.js +++ b/src/database/mongo/sorted.js @@ -141,8 +141,13 @@ module.exports = function(db, module) { key = {$in: key}; } + var limit = stop - start + 1; + if (limit <= 0) { + limit = 0; + } + db.collection('objects').find({_key: key}, {fields: fields}) - .limit(stop - start + 1) + .limit(limit) .skip(start) .sort({score: sort}) .toArray(function(err, data) {