Clear deno kv db
How can I clear out the database? using
list
requires the keys to be known, but I just want to clear out the instances that were added by mistake3 Replies
You would first create an es6-Set of valid (known) keys.
You could then use the above
This assumes you know the keys you want to keep.
You could retrieve the array of
You could then use the above
clearUnknown
method to filter your known keys to be kept.This assumes you know the keys you want to keep.
You could retrieve the array of
allKeys
, and edit it to hold only known keys. Place that in knownSet
i didn't know about
db.list({ prefix: [] })
. that's super useful. thanks!I use the above without the known test, to empty a kvdb. When this is used, its a good idea to close() the db to flush the write-ahead logs(WAL).
another useful utility method
Bulk-Transfer
: