kv-storage
kv-storage copied to clipboard
Range Queries Please 🤓
Digging through the docs there doesn’t appear to be a way to do range queries even though it looks like the keys are ordered.
My ideal API for this would just be to add optional start
, end
, and ascending
parameters to keys()
, values()
and entries()
. So:
const onehour = 1000 * 60 * 60
const now = Date.now()
// query for everything from the last hour
for await (let [key, value] of db.entries(now, now + onehour, true)) {
// do stuff
}
This might seem like a small feature but it’s something we rely on across the level
ecosystem for creating more complex things on top of IDB today.