node-redis icon indicating copy to clipboard operation
node-redis copied to clipboard

How do I apply optional parameters to methods?

Open shubik opened this issue 13 years ago • 2 comments

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?

shubik avatar Mar 08 '13 00:03 shubik

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' ]
});

brycebaril avatar Mar 08 '13 00:03 brycebaril

THANKS!

shubik avatar Mar 08 '13 01:03 shubik