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

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. Bulk Export / Import

    Export an entire IndexedDB store to JSON in one getAllRecords() call. Import back via a single transaction. Drop a .json file 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.

references