I have a use-case where I want to unconditionally delete all of the data persisted related to a specific “resource” without knowing each key in advance (so I can avoid the performance/financial/complexity costs of a call to the list
API). Right now, I use one durable object instance/id per “resource” in combination with deleteAll
*, but I would like the to be able to group multiple “resources” in the same durable object instance/id – so I am requesting that you add (at least) a prefix
option (like exists for the list
API, probably) to deleteAll
so that I can delete one “resource” in a durable object instance/id without deleting all other “resources” therein.
(*) Even my approach is somewhat inconvenient due to the lack of atomicity on deleteAll
, but my current technique is to always expect an atomic “usability” value created with storage.put("", {})
(the empty string ""
being the prefix of a range that might be non-atomically deleted) only after a successful call to deleteAll
, and keys can only be read/written under that prefix (""
) if the “usability” value exists (i.e. deleteAll
must be called if the “usability” value does not exist, and then the value can be subsequently created should deleteAll
succeed). The last piece of the protocol is to always delete the “usability” value (at the prefix ""
) before attempting to delete the prefixed range (with deleteAll
).