# mongoleaderboard

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

Latest version **0.0.13** (published 2013-07-04) · 0 weekly downloads

## Install

```sh
npm install mongoleaderboard
pnpm add mongoleaderboard
yarn add mongoleaderboard
bun add mongoleaderboard
```

## Health

**Score 10/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.13 |
| Published | 2013-07-04 |
| First published | 2013-07-01 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | 0.10.x |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Tom Kelly |
| Maintainers | tomkelly000 |

## Links

- npm: https://www.npmjs.com/package/mongoleaderboard
- Repository: https://github.com/tomkelly000/mongoleaderboard
- Issues: https://github.com/tomkelly000/mongoleaderboard/issues
- npm.io page: https://npm.io/package/mongoleaderboard

## Dependencies (2)

- [assert](https://npm.io/package/assert.md) 0.4.x
- [mongojs](https://npm.io/package/mongojs.md) 0.7.x

## Recent versions

- 0.0.13 (latest) — 2013-07-04
- 0.0.12 — 2013-07-01
- 0.0.11 — 2013-07-01
- 0.0.10 — 2013-07-01
- 0.0.9 — 2013-07-01
- 0.0.8 — 2013-07-01
- 0.0.7 — 2013-07-01
- 0.0.6 — 2013-07-01
- 0.0.5 — 2013-07-01
- 0.0.4 — 2013-07-01
- 0.0.3 — 2013-07-01
- 0.0.2 — 2013-07-01
- 0.0.1 — 2013-07-01

## README

# mongoleaderboard

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

## Usage

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

You can also specify options
``` js
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
``` js
// 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);
```

---
_Source: https://npm.io/package/mongoleaderboard · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
