Closed bhavnesh2211 closed 2 years ago
Could you please provide some steps to reproduce? Ideally a set of steps to be directly run via redis-cli
.
When I try this commands it's working fine in redis-cli, but when I'm trying to get in node app. It's returning only user_id that I added using ZADD.
How do you access the result? ZRANGE
with "WITHSCORES" returns an array as follows:
The following example using WITHSCORES shows how the command returns always an array, but this time, populated with element_1, score_1, element_2, score_2, ..., element_N, score_N.
@bhavnesh2211 it's a matter of your Node.js client, which I assume is redis
. Please use zRangeWithScores(key, min, max)
or ZRANGE_WITHSCORES(key, min, max)
to get back result with scores:
Hey, @tporadowski Thanks for the help. Where I can find these functions means it's not given in Redis's official document or in any tutorial I have seen.
@bhavnesh2211 I used Visual Studio Code with some Node.js extensions - and it provided those to me in "intellisense" code completion list like this:
I'm trying to get range of user with there scores, but it's returning only array of user_ids.
const getLeaderboard = async (tournamentUid) => (client.ZRANGE( tournamentUid, 0, 100, 'withscores', ));
This is my snippet.