getAllKeys() 方法在 IDBObjectStore interface returns an IDBRequest object retrieves record keys for all objects in the object store matching the specified parameter or all objects in the store if no parameters are given.

If a value is successfully found, then a structured clone of it is created and set as the result of the request object.

This method produces the same result for:

  • a record that doesn't exist in the database
  • a record that has an undefined value

To tell these situations apart, you need to call the openCursor() method with the same key. That method provides a cursor if the record exists, and no cursor if it does not.

句法

var request = objectStore.getAllKeys();
var request = objectStore.getAllKeys(query);
var request = objectStore.getAllKeys(query, count);
					

参数

query 可选
A value that is or resolves to an IDBKeyRange .
count 可选
Specifies the number of values to return if more than one is found. 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 one of the following types:

异常 描述
TransactionInactiveError This IDBObjectStore 's transaction is inactive.
DataError The key or key range provided contains an invalid key or is null.
InvalidStateError IDBObjectStore has been deleted or removed.

规范

规范 状态 注释
索引数据库 API 草案
The definition of 'getAllKeys()' 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 ≤79 Firefox 44 IE ? Opera 35 Safari 10.1 WebView Android 48 Chrome Android 48 Firefox Android 48 Opera Android 35 Safari iOS 10.3 Samsung Internet Android 5.0

图例

完整支持

完整支持

兼容性未知 ?

兼容性未知

另请参阅

元数据

  • 最后修改: