IDBCursorSync - Web APIs 编辑

Draft

This page is not complete.

Important: The synchronous version of the IndexedDB API was originally intended for use only with Web Workers, and was eventually removed from the spec because its need was questionable. It may however be reintroduced in the future if there is enough demand from web developers.

The IDBCursorSync interface of the IndexedDB API represents a cursor for iterating over multiple records in a database. You can have only one instance of IDBCursorSync representing a cursor, but you can have an unlimited number of cursors at the same time. Operations are performed on the underlying index or object store. It enables an application to synchronously process all the records in the cursor's range.

Method overview

bool continue (in optional any key);
void remove () raises (IDBDatabaseException);

Attributes

AttributeTypeDescription
countreadonly unsigned long longThe total number of objects that share the current key.
directionreadonly unsigned shortThe direction of traversal of the cursor. See Constants for possible values.
keyreadonly anyThe key for the record at the cursor's position.
valueany

The value for the record at the cursor's position. Setting this attribute can raise an IDBDatabaseException with the following codes:

DATA_ERR
If the underlying object store uses in-line keys and the property at the key path does not match the key in this cursor's position.
NOT_ALLOWED_ERR
If the underlying index or object store does not support updating the record because it is open in the READ_ONLY or SNAPSHOT_READ mode, or if an index record cannot be changed because the underlying index is auto-populated.
SERIAL_ERR
If the data being stored could not be serialized by the internal structured cloning algorithm.

Constants

ConstantValueDescription
NEXT0This cursor includes duplicates, and its direction is monotonically increasing in the order of keys.
NEXT_NO_DUPLICATE1This cursor does not include duplicates, and its direction is monotonically increasing in the order of keys.
PREV2This cursor includes duplicates, and its direction is monotonically decreasing in the order of keys.
PREV_NO_DUPLICATE3This cursor does not include duplicates, and its direction is monotonically decreasing in the order of keys.

Methods

continue()

Advances the cursor to the next position along its direction, to the item whose key matches the optional key parameter. If no key is specified, advance to the immediate next position. Returns false if the cursor has reached the end of its range; otherwise returns true.

bool continue (
  in optional any key
);
Parameters
key
The key to which to move the cursor's position.

remove()

Deletes the record at the cursor's position, without changing the cursor's position

void delete (
) raises (DatabaseException);
Exceptions

This method can raise an IDBDatabaseException with the following code:

NOT_ALLOWED_ERR
If the underlying index or object store does not support updating the record because it is open in the READ_ONLY or SNAPSHOT_READ mode.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:39 次

字数:7038

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文