I'm new to indexeddb. Let's say I put several objects to indexed db:
transaction.objectStore("some_store").put(some_object, some_key);
Now I want to get all keys from that object store. Is that possible? If yes, how?
Possible as Kristof said by using openCursor method. It is not efficient because requesting value cursor object might involve de-serialization.
You should also note that, your put method return primary key of the inserted object.
Currently, if you want very efficient keys retrive, index the keyPath for in-line key object store. For out-of-line object store you are out of luck. Using index, you can retrive keys as follow:
transaction.objectStore("some_store").index('id').openKeyCursor(); // here id is primary key path
There is a bug report for requesting openKeyCursor method directly object store. Hopefully next IndexedDB spec will have it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With