'Where is node-redis v4 documentation/migration guide?
node-redis refactored its API in v4 to support Promises. For some reason, they also decided to change the signature of most commands, which now don't obey any apparent logic. For example, this is the signature of ZADD:
.zAdd('key', { score: 1, value: 'value' })
And this one of ZRANGE:
.zRange(key, min, max, { BY: "SCORE", LIMIT: { offset , count } })
In ZINTERSTORE they even omit one parameter from the native Redis command.
My purpose is not to rant about the inconsistency in the new API, just to ask where is the migration guide, since the link in their page is broken. Or, should we just look into the source code (as I did)?
Solution 1:[1]
If you need to get scores, there's a new method for that
let rawData = await redis.zRangeWithScores(
key,
'+inf', // this means infinity
'-inf',
{
BY: 'SCORE',
REV: true
}
);
There are some useful questions and answers on this issues thread for node-redis
Mainly, that you need to reverse the min/max when calling the REV: true option, and that you use +inf instead of 0 and '-inf' instead of -1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | TetraDev |
