この記事は技術レビューを必要としています。ぜひご協力ください。
この記事はまだボランティアによって 日本語 に翻訳されていません。ぜひ MDN に参加して翻訳を手伝ってください!
There is a performance cost associated with looking at the value
property of a cursor, because the object is created lazily. To use a feature like getAll()
, Gecko would have to create all the objects at once. If you were just interested in looking at each of the keys, for instance, it would be much more efficient to use a cursor. If you were trying to get an array of all the objects in an object store, though, you could use getAll()
.
Syntax
var getAllKeysRequest = IDBIndex.getAll(query, count);
Returns
An IDBRequest
object on which subsequent events related to this operation are fired.
Parameters
- query Optional
- A key or an
IDBKeyRange
identifying the records 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.
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. |
Example
var myIndex = objectStore.index('index'); var getAllKeyRequest = myIndex.getAllKeys(); getAllKeysRequest.onsuccess = function() { console.log(getAllKeysRequest.result); }
Specification
Specification | Status | Comment |
---|---|---|
Indexed Database API (Second Edition) The definition of 'getAll()' in that specification. |
Editor's Draft | Initial definition. |
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() |
48.0 | 24.0 (24.0) [2] | No support | No support | No support |
getAllKeys() |
48.0 | 24.0 (24.0) [2] | No support | No support | No support |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | Firefox OS | IE Phone | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|
Basic support | 4.4 | (Yes) | 22.0 (22.0) | 1.0.1 | 10 | 22 | No support | (Yes) |
count() |
4.4 | (Yes) | 22.0 (22.0) | 1.0.1 | 10 | 22 | No support | (Yes) |
getAll() |
No support | 48.0 | 24.0 (24.0) [2] | 1.1 [2] | No support | No support | No support | 48.0 |
getAllKeys() |
No support | 48.0 | 24.0 (24.0) [2] | 1.1 [2] | No support | No support | No support | 48.0 |
[1] Behind dom.indexedDB.experimental
pref.
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.)