Share batches and commit collectively.
var db = level('db')
// Create a shared batch object
var fork = shared(db.batch())
// Those two modules will now add their operations to a fork of the original
// batch, and batch.write(...) will mark their work as done. Once both
// modules called batch.write(), all the operations will be executed in one
// atomic go.
moduleA.doSomething({ batch: fork() })
moduleB.doAnotherThing({ batch: fork() })
$ npm install level-shared-batch
Create a new fork for batch
.
MIT