Skip to content

Node.js based forum software built for the modern web

fix getSortedSetRange() if start>0 and stop is -1

barisusaklife3417538c99
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) {