Open shantanuthatte opened 8 years ago
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 :confused:
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.
So, in light of this bug, how can I get the entire list of keys?
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:
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 id
s? Is using filter
the only way for this?
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.
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
.
Have you got an example?
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...
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:
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