kv-storage icon indicating copy to clipboard operation
kv-storage copied to clipboard

Range Queries Please 🤓

Open mikeal opened this issue 4 years ago • 1 comments

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.

mikeal avatar Sep 06 '19 19:09 mikeal