seal-counter-storage

0.0.6 • Public • Published

seal-counter-storage

CircleCI AppVeyor

seal-counter-storage manages handling of counters persisted in a MongoDB.

Installation

$ npm install seal-counter-storage

Quick start

First you need to add a reference to seal-counter-storage within your application.

var counterStorage = require('seal-counter-storage');

Then you can connect to a MongoDB. For that call the connect function and provide the database's connection string using the url property:

counterStorage.connect({ url: 'mongodb://localhost:27017' }, function (err, storage) {
  // ...
})

Optionally, you may also specify the number of connection retries:

counterStorage.connect({
  url: 'mongodb://localhost:27017',
  connectionRetries: 10
}, function (err, storage) {
  // ...
})

Get next counter value

To get the next counter value call the getCounter function and provide at least its name and a callback. Optionally you can provide the increment as second argument, default increment is 1.

storage.getCounter('hugo', function (err, newCounterValue) {
  // ...
});

With increment:

storage.getCounter('hugo', 100, function (err, newCounterValue) {
  // ...
});

Running the build

To build this module use roboter.

$ bot

Readme

Keywords

none

Package Sidebar

Install

npm i seal-counter-storage

Weekly Downloads

0

Version

0.0.6

License

MIT

Last publish

Collaborators

  • manni19682