getAllKeys() 方法在 IDBIndex interface instantly retrieves the primary keys of all objects inside the index, setting them as the result of the request object.

句法

var allKeysRequest = IDBIndex.getAllKeys();
var allKeysRequest = IDBIndex.getAllKeys(query);
var allKeysRequest = IDBIndex.getAllKeys(query, count);
					

参数

query 可选
A key or an IDBKeyRange identifying the keys to retrieve. If this value is null or missing, the browser will use an unbound key range.
count 可选
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 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 getAllKeysRequest = myIndex.getAllKeys();
getAllKeysRequest.onsuccess = function() {
  console.log(getAllKeysRequest.result);
}
					

规范

规范 状态 注释
索引数据库 API 草案
The definition of 'getAll()' in that specification.
推荐 初始定义。
索引数据库 API 草案
The definition of 'getAll()' in that specification.
推荐

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
getAllKeys Chrome 48 Edge ≤18 Firefox 44 Disabled
44 Disabled
Disabled From version 44: this feature is behind the dom.indexedDB.experimental preference. To change preferences in Firefox, visit about:config.
IE No Opera 35 Safari 10.1 WebView Android 48 Chrome Android 48 Firefox Android 44 Disabled
44 Disabled
Disabled From version 44: this feature is behind the dom.indexedDB.experimental preference. To change preferences in Firefox, visit about:config.
Opera Android 35 Safari iOS 10.3 Samsung Internet Android 5.0

图例

完整支持

完整支持

不支持

不支持

用户必须明确启用此特征。

用户必须明确启用此特征。

另请参阅

元数据

  • 最后修改: