npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

db-lock

1.2.0

@mafintosh

npmHomeRepoSnykSocket
Downloads:156
$ npm install db-lock
DailyWeeklyMonthlyYearly

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