0.0.13 • Published 11 years ago

mongoleaderboard v0.0.13

Weekly downloads
53
License
-
Repository
github
Last release
11 years ago

mongoleaderboard

A node.js module for implementing a simple leaderboard with mongodb

Usage

var Leaderboard = require('mongoleaderboard');
var mongoUri = 'mongodb://localhost/mydb';
var leaderboard = new Leaderboard(mongoUri);

You can also specify options

var options = {};
// specify a leaderboard at collection named highscores
// with page sizes of 5, 2 pages, that refreshes daily at 5:00
options.collection = 'highscores'; // defaults to leaderboard
options.page_size = 5; // defaults to 20
options.num_pages = 2; // defaults to 1
options.start_time = { // time of day to refresh
        'milliseconds':0,
        'seconds':0,
        'minutes':0,
        'hours':5
    }; // defaults to midnight
options.duration = 1000 * 60 * 60 * 24; // time in milliseconds
		   	                // defaults to infinity
var leaderboard = new Leaderboard(mongoUri, options);

API

// executes the callback passing the argument true (1) 
// if the score is a high score, otherwise pass  false (0)
leaderboard.check(score, callback);

// overwrites the lowest score on the leaderboard if the given score 
// is larger. if the force parameter is supplied, it will overwrite
// no matter what. member is an object with the other info a highscore needs
// e.g. member = {'initials':'TJK'}
// executes the callback with two arguments, err and the saved member object
leaderboard.postHighScore(highscore, member, callback, force);
// also aliased as
leaderboard.post(highscore, member, callback, force);

// executes the callback on the two arguments err and scores,
// where scores is an array of objects
leaderboard.getHighScores(callback);
// also aliased as
leaderboard.get(callback);
0.0.13

11 years ago

0.0.12

11 years ago

0.0.11

11 years ago

0.0.10

11 years ago

0.0.9

11 years ago

0.0.8

11 years ago

0.0.7

11 years ago

0.0.6

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago