README
lockgoose
A simple library for creating locks with mongoose.
Install
npm i lockgoose
Requires mongoose ^5.0.0
to be installed as a dependency.
Usage
const lockgoose = require('lockgoose');
// (initialise your mongoose connection here)
// initialise lockgoose
await lockgoose.init({ /* options */ });
// create a lock
const lock = await lockgoose.lock('tag');
// unlock a lock in-scope
await lock.unlock();
// unlock a lock created earlier
await lockgoose.unlock('tag');
// reinit index on locks (useful if you are dropping database during testing)
await lockgoose.init();
Test
Testing provided by Jest and linting by eslint.
npm test
npm run test:lint