Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add start/end keys for iterate() #565

Open
nolanlawson opened this issue May 15, 2016 · 1 comment
Open

Add start/end keys for iterate() #565

nolanlawson opened this issue May 15, 2016 · 1 comment

Comments

@nolanlawson
Copy link
Contributor

Currently, you can store a lot of data in LocalForage sorted by key, but you can't easily "slice" the data to get a subset of those items. The only way is to call iterate(), which currently reads the entire database into memory and therefore is not super efficient.

My proposal: enhance the iterate() API by allowing users to do:

iterate(startkey, endkey, iteratorCallback, successCallback)

If neither startkey/endkey are specified, then you get the old behavior. If only one is specified, you get startkey (similar to Array.prototype.slice()). To keep things simple, both of them should be inclusive, and then users can get exclusive behavior by just skipping those values in their iteratorCallback function.

What do you all think? If I have some spare cycles and if this is a popular proposal, I could try to take a crack at it.

@tofumatt
Copy link
Member

Sounds good to me! I'm for it! 👍🏻

  • tofumatt

On 15 May 2016 at 15:22:57, Nolan Lawson (notifications@github.com) wrote:

Currently, you can store a lot of data in LocalForage sorted by key, but
you can't easily "slice" the data to get a subset of those items. The only
way is to call iterate(), which currently reads the entire database into
memory and therefore is not super efficient.

My proposal: enhance the iterate() API by allowing users to do:

iterate(startkey, endkey, iteratorCallback, successCallback)

If neither startkey/endkey are specified, then you get the old behavior.
If only one is specified, you get startkey (similar to
Array.prototype.slice()). To keep things simple, both of them should be
inclusive, and then users can get exclusive behavior by just skipping those
values in their iteratorCallback function.

What do you all think? If I have some spare cycles and if this is a
popular proposal, I could try to take a crack at it.


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#565

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

No branches or pull requests

2 participants