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

index["openKeyCursor"] is undefined #157

Open
shantanuthatte opened this issue Feb 1, 2016 · 10 comments
Open

index["openKeyCursor"] is undefined #157

shantanuthatte opened this issue Feb 1, 2016 · 10 comments

Comments

@shantanuthatte
Copy link

See https://jsfiddle.net/fok7w86x/2/

Breaks on: https://github.com/aaronpowell/db.js/blob/master/dist/db.js#L288

Fails on Chrome 47.0.2526.111 (64-bit) and Firefox

@aaronpowell
Copy link
Owner

This looks like a bug in the API that is being surfaced, keys shouldn't be available on all if you don't specify the indexName. The reason for this that openKeyCursor which is used exists on IDBIndex not IDBStore which is used when you don't provide an index (see: https://www.w3.org/TR/IndexedDB/#widl-IDBIndex-openKeyCursor-IDBRequest-any-range-IDBCursorDirection-direction).

I'm not quite sure how best to handle this for the API 😕

@shantanuthatte
Copy link
Author

Sorry for the briefness, of the issue. I just wanted to get people here involved, and make sure I wasn't doing anything dumb.

Strangely enough it works in Chrome 48.0.2564.97 m (64-bit) on Windows
And failed on Chrome 47.0.2526.111 (64-bit) on Ubuntu
And works on Firefox 44 on Windows.
And fails on Firefox 44 on Mac.

@shantanuthatte
Copy link
Author

So, in light of this bug, how can I get the entire list of keys?

@aaronpowell
Copy link
Owner

Because you need to specify the index that you want the key's of the usage that you had doesn't really make sense, you're saying you want the keys, but not where you want them from.

Judging from your usage I'm going to guess that you want the "primary keys", aka all the id's, so to do that you need to "name" the index, like I have here:

http://jsbin.com/pokehe/edit?js,console,output

@shantanuthatte
Copy link
Author

Hey,

Thanks for that! Worked like a charm.

Also, I seem to run into another issue,

s.people.query('name').only('Aaron').all().keys().execute()

returns, ['Aaron','Aaron',...]. How can I search/filter by index and then get the ids? Is using filter the only way for this?

@aaronpowell
Copy link
Owner

If you're just wanting the keyPath for an object store you need to make a named index, as I did with the people object store in the above demo.

@shantanuthatte
Copy link
Author

Well, I did create indexes on both name and id. What I'm trying to do is to get id for all people with name as Aaron.

@aaronpowell
Copy link
Owner

Have you got an example?

@brettz9
Copy link
Contributor

brettz9 commented Mar 27, 2016

As far as the original question, I think this is no longer an issue because, per the latest draft spec and in at least Chrome and Firefox, IDBStore now has openKeyCursor too...

@brettz9 brettz9 mentioned this issue Mar 27, 2016
@brettz9
Copy link
Contributor

brettz9 commented Apr 11, 2016

Could we close this? Neither Chrome nor Firefox are failing on the originally reported issue. I think another issue could be filed if @shantanuthatte still has the other question/issue, but I've added the following with data to demonstrate how to get the IDs:

http://jsbin.com/tazekubujo/1/edit?html,js,console,output

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

3 participants