node-redis
node-redis copied to clipboard
How do I apply optional parameters to methods?
Hi Matt, How do can I apply optional params, e.g.
ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count]
I need to use count because otherwise it returns thousands of results? Or should I apply limit to results already in my code?
You just add the parameters you need as inputs to the zrangebyscore method:
var r = require("redis").createClient();
r.zadd("myzset", 1, "one");
r.zadd("myzset", 1, "uno");
r.zadd("myzset", 2, "two");
r.zrangebyscore("myzset", "-inf", "+inf", "limit", 0, 2, function (err, replies) {
console.log(replies); // [ 'one', 'uno' ]
});
THANKS!