mozilla

IDBIndex.getAllKeys()

This article is in need of a technical review.

The proposed getAllKeys() method of the IDBIndex interface would instantly retrieve the keys of all objects inside an object store, setting them as the result of the request object.

Note: This method is not currently included in the IndexedDB spec or available in any browsers, but is being considered for future addition.

Syntax

var myIndex = objectStore.index('index');
var getAllKeysRequest = myIndex.getAllKeys();

Returns

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

Exceptions

This method may raise a DOMException with a DOMError of the following types:

Exception Description
TransactionInactiveError This IDBIndex's transaction is inactive.
InvalidStateError The IDBIndex has been deleted or removed.
 

Example

var myIndex = objectStore.index('index');
var getAllKeyRequest = myIndex.getAllKeys();
getAllKeysRequest.onsuccess = function() {
  console.log(getAllKeysRequest.result);
}

Specification

This method is not currently included in the IndexedDB spec or available in any browsers, but is being considered for future addition. Its IDL syntax is as follows:

IDBRequest getAllKeys (in any key);

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 23webkit
24
10 moz
16.0 (16.0)
10, partial 15 7.1
count() 23 22.0 (22.0) 10, partial 15 7.1
getAll() and getAllKeys() Not supported 24.0 (24.0)
behind dom.indexedDB.experimental  pref
Not supported Not supported Not supported
Feature Android Firefox Mobile (Gecko) Firefox OS IE Phone Opera Mobile Safari Mobile
Basic support 4.4 22.0 (22.0) 1.0.1 10 22 Not supported
count() 4.4 22.0 (22.0) 1.0.1 10 22 Not supported
getAll() and getAllKeys() Not supported 24.0 (24.0)
behind dom.indexedDB.experimental  pref
1.1 behind
dom.indexedDB.experimental  pref
Not supported Not supported Not supported

Be careful in Chrome as it still implements the old specification along the new one. Similarly it still has the prefixed webkitIndexedDB property even if the unprefixed indexedDB is present.

See also

Document Tags and Contributors

Contributors to this page: fscholz, chrisdavidmills
Last updated by: fscholz,