v141 · offline / storage
IndexedDB getAllRecords() and direction option for getAll()/getAllKeys()
This feature adds the getAllRecords() API to IndexedDB's IDBObjectStore and IDBIndex. It also adds a direction parameter to getAll() and getAllKeys(). This functionality enables certain read patterns to be significantly faster when compared to the existing alternative of iteration with cursors. One key workload from a Microsoft property showed a 350ms imp
concepts
-
getAllRecords
IndexedDB gains getAllRecords() (returns key+value pairs) and a direction option on the existing getAll/getAllKeys. Cleaner than orchestrating a cursor for bulk reads.
-
Reverse Pagination
The activity-feed workload — newest first, paged. Side-by-side timing of
getAllRecords({direction:"prev"})against the cursor dance, against a real seeded store of 200 records. -
Keys then Values
A document list that paints titles via
getAllKeys({direction:"prev", count})first and only fetches each body on click. The deferred-value pattern the Edge explainer specifically called out. -
Pagination Demo
Forward and reverse pagination through a seeded 500-record store using
getAllRecords({direction, count, query}). Page controls advance the key range cursor without opening a JS cursor loop — timing comparison shows the per-page latency drop. -
Index Range Query
500 orders seeded across 3 categories and 180 days. Filter by date range and category using
idx.getAllRecords({ query: IDBKeyRange.bound(from, to) })on a secondary index — side-by-side timing against the equivalent cursor loop. -
Bulk Export / Import
Export an entire IndexedDB store to JSON in one
getAllRecords()call. Import back via a single transaction. Drop a.jsonfile or paste the snapshot — with progress, timing, and a before/after count.
why it shipped
Decrease the latency of database read operations. By retrieving the primary key, value and index key for database records through a single operation, getAllRecords() reduces the number of JavaScript events required to read records. Each JavaScript event runs as a task on the main JavaScript thread. These tasks can introduce overhead when reading records requires a sequence of tasks that go back and forth between the main JavaScript thread and the IndexedDB I/O thread.