IDBIndex.openCursor()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Note: This feature is available in Web Workers.
Phương thức openCursor() của giao diện IDBIndex trả về một đối tượng IDBRequest và, trong một luồng riêng biệt, tạo một cursor trên phạm vi khóa đã chỉ định.
Cú pháp
js
openCursor()
openCursor(query)
openCursor(query, direction)
Tham số
queryOptional-
Khóa hoặc phạm vi khóa để so khớp.
directionOptional-
Hướng di chuyển của cursor.
Giá trị trả về
Một đối tượng IDBRequest.
Ngoại lệ
TransactionInactiveErrorDOMException-
Transaction của đối tượng này đang không hoạt động.
DataErrorDOMException-
Khóa hoặc phạm vi khóa không hợp lệ.
Ví dụ
js
const request = myIndex.openCursor();
request.onsuccess = () => {
console.log(request.result);
};
Thông số kỹ thuật
| Specification |
|---|
| Indexed Database API 3.0> # ref-for-dom-idbindex-opencursor②> |