1.0.0 • Published 1 year ago

bee-transaction v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

bee-transaction

Automatic batch for Hyperbee

npm i bee-transaction

Usage

It creates a batch, locks, gives you a callback to use it, and flushes or closes if any error.

const beeTransaction = require('bee-transaction')

const db = new Hyperbee(...)

const id = await beeTransaction(db, async function (b) {
  const userId = 1

  await b.put('/users/' + userId, { email, password })
  await b.put('/index/email/' + email, userId)

  return userId
})

console.log(id) // => 1

License

MIT

1.0.0

1 year ago