getAll()
方法在
IDBIndex
interface retrieves all objects that are inside the index.
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()
, the browser has to create all the objects at once. If you are just interested in looking at each of the keys, for instance, it is more efficient to use a
cursor
. If you are trying to get an array of all the objects in an object store, though, you should use
getAll()
.
var getAllKeysRequest = IDBIndex.getAll(); var getAllKeysRequest = IDBIndex.getAll(query); var getAllKeysRequest = IDBIndex.getAll(query, count);
IDBKeyRange
identifying the records to retrieve. If this value is null or missing, the browser will use an unbound key range.
0
or greater than
2
32
-1
a
TypeError
exception will be thrown.
IDBRequest
object on which subsequent events related to this operation are fired.
此方法可能引发
DOMException
of the following types:
| 异常 | 描述 |
|---|---|
TransactionInactiveError
|
This
IDBIndex
's transaction is inactive.
|
InvalidStateError
|
IDBIndex
has been deleted or removed.
|
A
TypeError
exception is thrown if the
count
parameter is not between
0
and
2
32
-1
included.
var myIndex = objectStore.index('index');
var getAllRequest = myIndex.getAll();
getAllRequest.onsuccess = function() {
console.log(getAllRequest.result);
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
索引数据库 API 草案
The definition of 'getAll()' in that specification. |
推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
getAll
|
Chrome 48 | Edge ≤18 | Firefox 44 | IE No | Opera 35 | Safari 10.1 | WebView Android 48 | Chrome Android 48 | Firefox Android 44 | Opera Android 35 | Safari iOS 10.3 | Samsung Internet Android 5.0 |
完整支持
不支持
IDBDatabase
IDBTransaction
IDBKeyRange
IDBObjectStore
IDBCursor
IDBIndex
IDBCursor
IDBCursorSync
IDBCursorWithValue
IDBDatabase
IDBDatabaseException
IDBDatabaseSync
IDBEnvironment
IDBEnvironmentSync
IDBFactory
IDBFactorySync
IDBIndexSync
IDBKeyRange
IDBObjectStore
IDBObjectStoreSync
IDBOpenDBRequest
IDBRequest
IDBTransaction
IDBTransactionSync
IDBVersionChangeEvent
IDBVersionChangeRequest