The getAllKeys() method of the IDBIndex interface instantly retrieves the primary keys of all objects inside the index, setting them as the result of the request object.
Syntax
var allKeysRequest = IDBIndex.getAllKeys(); var allKeysRequest = IDBIndex.getAllKeys(query); var allKeysRequest = IDBIndex.getAllKeys(query, count);
Parameters
- query Optional
- A key or an
IDBKeyRangeidentifying the keys to retrieve. If this value is null or missing, the browser will use an unbound key range. - count Optional
- The number records to return. If this value exceeds the number of records in the query, the browser will only retrieve the first item. If it is lower than
0or greater than232-1aTypeErrorexception will be thrown.
Return value
An IDBRequest object on which subsequent events related to this operation are fired.
Exceptions
This method may raise a DOMException of the following types:
| Exception | Description |
|---|---|
TransactionInactiveError |
This IDBIndex's transaction is inactive. |
InvalidStateError |
The IDBIndex has been deleted or removed. |
A TypeError exception is thrown if the count parameter is not between 0 and 232-1 included.
Example
var myIndex = objectStore.index('index');
var getAllKeysRequest = myIndex.getAllKeys();
getAllKeysRequest.onsuccess = function() {
console.log(getAllKeysRequest.result);
}
Specification
| Specification | Status | Comment |
|---|---|---|
| Indexed Database API Draft The definition of 'getAll()' in that specification. |
Recommendation | Initial definition. |
| Indexed Database API Draft The definition of 'getAll()' in that specification. |
Recommendation |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
getAllKeys | Chrome Full support 48 | Edge Full support ≤18 | Firefox
Full support
44
| IE No support No | Opera Full support 35 | Safari Full support 10.1 | WebView Android Full support 48 | Chrome Android Full support 48 | Firefox Android
Full support
44
| Opera Android Full support 35 | Safari iOS Full support 10.3 | Samsung Internet Android Full support 5.0 |
Legend
- Full support
- Full support
- No support
- No support
- User must explicitly enable this feature.
- User must explicitly enable this feature.
See also
- Using IndexedDB
- Starting transactions:
IDBDatabase - Using transactions:
IDBTransaction - Setting a range of keys:
IDBKeyRange - Retrieving and making changes to your data:
IDBObjectStore - Using cursors:
IDBCursor - Reference example: To-do Notifications (view example live.)
