Durable Objects - Transactional Storage API Feedback

It would be great if the ‘list’ API for an object had an additional parameter like keyNamesOnly in addition to limit, offsets such that only the key names are returned rather than both keys and actual values.

Durable objects seems to align well with a ‘wide entity’ no SQL pattern and given the actual values of keys could be a) quite large (in some cases a few megabytes) and b) lots of them, this would be a simple change which is non-breaking change and great enhancement out of beta .

With object keys being the only data structure for a durable object, and the fact the names are dynamic there would be lots of times key names need to discovered at runtime on an object.

1 Like

Keys are limited to a max size of 2048 bytes and values are limited to 32 KiB :

Thanks for the reply. But I was referring to the actual values which are always returned in a list operation. An object with 100 keys each 30kb is returning 3MB of data when you’re simply only trying to find out the names of the keys used on your object!

Good suggestion and I suppose it is not super hard to implement, like an Object.keys(o).

Temporary Solution 1
Use a second Durable Object to store keys like {key1:‘key1’, key2:‘key2’}. Risk of desynchronization with the first Durable Object

Temporary Solution 2
In your current Durable object, reserve a special key to store an array with all the keys, like : {myKeys:[key1, key2,…]}. It’s OK since JS is thread safe, only 1 access at a time.

Thanks. Agree it’s a simple parameter to add.

Solution 2 is probably the best ‘workaround’. Solution 1 as you say has consistency issues, and as one durable object can’t call another it would need to be delegated to the calling client code to manage internal cross object state which would be an absolute pain.