Open vweevers opened 1 year ago
Only question is, if db
is a sublevel, should it forward { prewrite: false }
to its parent database? I think no, to keep it isolated.
The prewrite
hook is fast, so technically this could also be solved in userland. Like so:
const bypass = Symbol('bypass')
db.hooks.prewrite.add(function (op, batch) {
if (op[bypass]) return
})
await db.del('foo', { [bypass]: true })
And adding a prewrite
option wouldn't be a breaking change, so I'm removing this from the v2 milestone. Not a blocker.
Context
I'm working on a rewrite of
level-ttl
, not because I need it, but to make it use hooks and find out what gaps we in that API.Problem
If a plugin like
level-ttl
uses theprewrite
hook but also has a background job that writes to the same db, it will trigger its own hook function (as well as other hook functions). E.g.:Solution
As well as: