Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Range Queries Please 🤓 #75

Open
mikeal opened this issue Sep 6, 2019 · 1 comment
Open

Range Queries Please 🤓 #75

mikeal opened this issue Sep 6, 2019 · 1 comment

Comments

@mikeal
Copy link

mikeal commented Sep 6, 2019

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.

@LinusU
Copy link

LinusU commented Feb 20, 2020

I would like to second this and also add that I would love to be able to specify if start & end should be inclusive or exclusive. In my package fanny-pack I've solved it by taking a range object that can have gt/gte & lt/lte. That way you can also only specify a lower, or only a upper bound if you want to.

ref: https://github.com/LinusU/fanny-pack#keyrange

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants