felixge/node-dirty

db.rm(key) doesn't really remove the entry from the db file on disk

nabeel-nasir opened this issue · 1 comments

It adds a new entry for the key which doesn't have any value. For example, the following code

db.set('john', {eyes: 'blue'}, () => console.log("set!") );
db.rm('john', () => console.log("deleted") );

results in the db file looking like this:

{"key":"john","val":{"eyes":"blue"}}
{"key":"john"}

Is this expected behavior? I can however confirm that, db.forEach() works as expected (no entry for the key john).

Is this expected behavior?

Yes. From README.md (emphasis added):

A tiny & fast key value store with append-only disk log.

and:

dirty.rm(key, cb)

Removes the record with the given key. This is identical to setting the key's value to undefined.