You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently deleting keys adds a null value to the db regardless of if the key exists or not. It would be great to check if the key exists or not before deleting to avoid unnecessary data in the db.
I wrote some tests for this the first and last are currently failing.
tape('does not delete non existent keys',function(t){vardb=create.one()db.del('hello',function(err,node){t.error(err,'no error')t.same(db._writers[0].length(),0)t.end()})})tape('does not delete non existent keys',function(t){vardb=create.one()db.put('hello','world',function(err,node){t.error(err,'no error')db.del('hello',function(err,node){t.error(err,'no error')t.same(db._writers[0].length(),2)t.end()})})})tape('does not delete non existent keys',function(t){vardb=create.one()db.put('hello','world',function(err,node){t.error(err,'no error')db.del('hello',function(err,node){t.error(err,'no error')t.same(db._writers[0].length(),2)db.del('hello',function(err,node){t.error(err,'no error')t.same(db._writers[0].length(),2)t.end()})})})})
The text was updated successfully, but these errors were encountered:
@mafintosh just playing around with writing a staging area for hyperdb's and realised that recording a del for a non-existent key is a really key feature. It helps to easily see if the staged db has deleted a key without having to add that key.
I think doing just as you suggest, not overwriting puts is a better idea than not adding the del for non-existent items.
Currently deleting keys adds a null value to the db regardless of if the key exists or not. It would be great to check if the key exists or not before deleting to avoid unnecessary data in the db.
I wrote some tests for this the first and last are currently failing.
The text was updated successfully, but these errors were encountered: