Is it possible to get key and value in one request, or, filter the value?

I’m building a huge namespace list of key values (KV). The list contain something like

   { key: '', value: { views: 100, type: 'extreme' } }
   { key: '', value: { views: 9, type: 'low' } }

So… to get the keys that the value it’s > 0 and type == ‘extreme’, I need to do the following requests

  1. storage/kv/namespaces/{namespaceId}/keys/?cursor=1 // 1000 items

  2. storage/kv/namespaces/{namespaceId}/values/1

  3. storage/kv/namespaces/{namespaceId}/values/2…

  4. storage/kv/namespaces/{namespaceId}/values/1000

  5. storage/kv/namespaces/{namespaceId}/keys/?cursor=2 // +1000 items

  6. storage/kv/namespaces/{namespaceId}/values/1

  7. storage/kv/namespaces/{namespaceId}/values/2…

  8. storage/kv/namespaces/{namespaceId}/values/100

So, this will tame some time and requests.

My questions is; Is there a better way to bring only the keys + values that I want?

Not from what I can gather from the documentation,

Your best bet might be trying to incorporate the type as prefix into the name (i.e. extreme-key or low-key) and then use the filter of list() to filter for these. Though I am not sure that filter is also available on the web interface and not just via the JavaScript functions.

1 Like

Just to chime in here, “bulk get” is a thing that’s on my radar as a feature; it’s true we don’t have anything that makes this simple right now, and this advice (prefixing) is the best thing you can do at the moment.