#84: Indexed DB getAll(), openKeyCursor() and objectStoreNames

Visit on Github.

Opened Sep 24, 2015

There are a handful of new methods/attributes in the Indexed DB "Second Edition" with implementations in both FF and Chrome that we'd like feedback on. These are additions of new methods to existing interface objects in the API, and do not change the behavior of any existing methods. All can be feature detected.

IDBObjectStore.getAll() IDBObjectStore.getAllKeys() IDBIndex.getAll() IDBIndex.getAllKeys()

Like get()/getKey(), these take a query (null or key or key range), but also an optional count, and yield a JS Array with all matching results. The alternatives today are issuing multiple parallel get() calls (if keys are known) or iterating a cursor over the range (if keys are not known). Avoiding multiple event dispatches can be a significant performance improvement and reduce main thread contention, as well as simplifying application logic.

IDBObjectStore.openKeyCursor()

IDBIndex has openCursor() and openKeyCursor(), where the latter avoids fetching values and saves on the transport/deserialization overhead when only existence testing is known, e.g. for joins. This gives IDBObjectStore the same lighter-weight option in addition to the existing IDBObjectStore.openCursor()

IDBTransaction.objectStoreNames

This is a convenience attribute that yields the stores in the scope of the transaction, as specified when starting the transaction. For upgrade transactions it yields the same thing as db.objectStoreNames. This attribute has shipped (unprefixed, not behind a flag) in FF for many versions.

NOTE: There are other additions marked "new in this edition" in the ED; we are not as far along with design/review/discussion of those. Also, there are discussions around integration with Promises, improvements to indexes and transactions, more powerful queries, and a several other additional features - see https://github.com/w3c/IndexedDB/issues - that haven't made it into the ED. So right now we're hoping for feedback on just the subset above.

Discussions