rank-me
Minimalistic leaderboards for the ranking of non-unique usernames.
Every new name/score pair added to a leaderboard will generate a unique id associated with the transaction. This id can be stored and used to query additional information about the transaction at a later time.
Installation
npm install rank-me
API
Constructor
var Leaderboard = ; var leaderboard = 'leaderboard_id' options;
Options
host
(default: 127.0.0.1)- The host address of the redis server.
port
(default: 6379)- The port of the redis server.
db
(default: 0)- Select the specified redis DB.
Methods
getScoreCount(callback)
Gets the total # of stores stored in the leaderboard.
leaderboard;
addScore(name, score, callback)
Adds a score to the leaderboard for a given user name.
Names are not required to be unique. For every name/score that
is added to the leaderboard, a unique entryId
will be generated.
This unique id is passed as a parameter to the callback of addScore
.
Using this unique id, information about the added score entry can be
queried if desired.
leaderboard;
getRank(entryId, callback)
Gets the rank for a given leaderboard entry.
leaderboard;
getScoresForRankRange(fromRank, toRank, callback)
Gets the names and scores for a given range of ranks.
Note that fromRank
and toRank
indices are both inclusive.
// Get the top 3 ranks:leaderboard;