IDBIndex: getAllRecords() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The getAllRecords() method of the IDBIndex interface retrieves all records (including index keys, primary keys, and values) from the index.

getAllRecords() effectively combines the functionality of getAllKeys() and getAll() by enumerating both primary keys and values at the same time. This combined operation enables certain data retrieval patterns to be significantly faster than alternatives such as iteration with cursors.

Syntax

js
getAllRecords()
getAllRecords(options)

Parameters

An options object whose properties can include:

query Optional

A key or an IDBKeyRange identifying the records to retrieve. If this value is null or not specified, the browser will use an unbound key range.

count Optional

The number of records to return. If this value exceeds the number of records in the query, the browser will retrieve only the queried records. If the value is less than 0 or greater than 2^32 - 1, a TypeError exception will be thrown.

direction Optional

An enumerated value specifying the direction in which the records are traversed. Possible values are:

next

The records are traversed from the beginning, in increasing key order. This is the default value.

nextunique

The records are traversed from the beginning, in increasing key order. For every key with duplicate records, only the record closest to the start is yielded.

prev

The records are traversed from the end, in decreasing key order.

prevunique

The records are traversed from the end, in decreasing key order. For every key with duplicate records, only the record closest to the start is yielded.

Return value

An IDBRequest object on which subsequent events related to this operation are fired.

If the operation is successful, the value of the request's result property is an array of objects representing all the records that match the given query, up to the number specified by count (if provided).

Each object contains the following properties:

key

A value representing the record's key.

primaryKey

A value representing the key of the record in the index's associated IDBObjectStore.

value

A value representing the record's value.

Exceptions

This method may raise a DOMException of the following types:

InvalidStateError DOMException

Thrown if the IDBIndex or its associated IDBObjectStore has been deleted or removed.

TransactionInactiveError DOMException

Thrown if this IDBIndex's transaction is inactive.

TypeError DOMException

Thrown if the count parameter is not between 0 and 2^32 - 1, inclusive.

Examples

js
const query = IDBKeyRange.lowerBound("myKey", true);
const objectStore = transaction.objectStore("contactsList");
const myIndex = objectStore.index("lastName");

const myRecords = (myIndex.getAllRecords({
  query,
  count: "100",
  direction: "prev",
}).onsuccess = (event) => {
  console.log("Records successfully retrieved");
});

Specifications

Specification
Indexed Database API 3.0
# ref-for-dom-idbindex-getallrecords①

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
getAllRecords
Experimental
Chrome – Full support
Chrome 141 (Release date: 2025-09-30)
footnote Full support
Edge – Full support
Edge 141 (Release date: 2025-10-03)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 125 (Release date: 2025-12-04)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 141 (Release date: 2025-09-30)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 93 (Release date: 2025-11-25)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – Full support
WebView Android 141 (Release date: 2025-09-30)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.

See also