Mongo Sequential
Create primary keys or another sequential number with a mongodb hosted counter.
Uses the findOneAndUpdate
from mongodb
to guarantee unique keys.
Use Promises or callbacks. If you pass a callback it will be called with
standard node convention of cb(err, result)
. Promises are implemented using
bluebird.
Exports: increment(collection, name[, cb(err, count)]) -> (Promise -> Integer)
Install
npm install mongo-sequential
Usage
var mongodb = ;var increment = ; mongodb;
Test
Requires a running mongodb on localhost
npm test