Does kv delete recursively?
For example, if I have entries with keys:
['users', 1]
, ['users', 2]
,
will kv.delete(['users'])
delete both of those entries?5 Replies
If the only way is to list and delete, it would be useful to allow the kv.delete op to accept the same selector as kv.list, to allow the underlying implementation to perform an efficient mass delete.
Maybe the selector could be extended to take a 'keys' property too, then list could also be used as a consistent API with all the abilities of get/getMany/list, and delete would then also have this flexibility too.
kv.delete()
only deletes a single entry.Single key delete is required for FDB - OCC and MVCC
FoundationDB combines optimistic concurrency control (OCC) and multi-version concurrency control (MVCC). Each transaction requires a versionstamp that are assigned sequentially (per transaction).
This wouldn't play nicely with bulk operations.
I'm not familiar with how FoundationDB works, but that's really an implementation detail. I don't think it should affect the ability to implement high level developer friendly APIs of Deno.KV. There is no reason the SQLite implementation couldn't perform a mass delete. If for FoundationDB the op translates to a list and individual deletes under the covers then so be it, future or alternative implementations may be able to improve on this without troubling the end users of Deno.KV with these details.
I'm thinking that eventually there will be a higher level wrapper in the
Deno.std
lib, that may provide these features. In the mean time, a simple cursor loop of a few lines of code should work fine.