1.2.0 • Published 6 months ago
db-lock v1.2.0
db-lock
Simple concurrent lock for DB patterns
npm install db-lock
Usage
const DBLock = require('db-lock')
const l = new DBLock({
async enter () {
return db.transaction()
},
async exit (tx) {
await tx.flush()
}
})
const tx = await l.enter() // opens the tx on first enter
// ... do stuff
await l.exit() // flushes the tx on last exit
License
Apache-2.0