Table of Contents

Class IDBCursor

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll
NOTE
Not to be confused with IDBCursorWithValue which is just an IDBCursor interface with an additional value property.
[Value("IDBCursor")]
public class IDBCursor
Inheritance
IDBCursor
Derived
Inherited Members

Remarks

The IDBCursor interface of the IndexedDB API represents a cursor for traversing or iterating over multiple records in a database.

The cursor has a source that indicates which index or object store it is iterating over. It has a position within the range, and moves in a direction that is increasing or decreasing in the order of record keys. The cursor enables an application to asynchronously process all the records in the cursor's range.

You can have an unlimited number of cursors at the same time. You always get the same IDBCursor object representing a given cursor. Operations are performed on the underlying index or object store.

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Reference example: To-do Notifications (view example live).

See also on MDN

Constructors

IDBCursor()

public IDBCursor()

Properties

Direction

The direction read-only property of the
IDBCursor interface is a string that returns the
direction of traversal of the cursor (set using
OpenCursor(dynamic, IDBCursorDirection) for example). See the Value
section below for possible values.

[Value("direction")]
public IDBCursorDirection Direction { get; }

Property Value

IDBCursorDirection

A string indicating the direction in which the cursor is traversing the data.
Possible values are:

Remarks

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

Key

The key read-only property of the
IDBCursor interface returns the key for the record at the cursor's
position. If the cursor is outside its range, this is set to undefined. The cursor's
key can be any data type.

[Value("key")]
public dynamic Key { get; }

Property Value

dynamic

A value of any type.

Remarks

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

PrimaryKey

The primaryKey read-only property of the
IDBCursor interface returns the cursor's current effective key. If the
cursor is currently being iterated or has iterated outside its range, this is set to
undefined. The cursor's primary key can be any data type.

[Value("primaryKey")]
public dynamic PrimaryKey { get; }

Property Value

dynamic

A value of any data type.

Remarks

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

Request

The request read-only property of the IDBCursor interface returns the IDBRequest used to obtain the cursor.

[Value("request")]
public IDBRequest Request { get; }

Property Value

IDBRequest

An IDBRequest object instance.

Remarks

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

Source

The source read-only property of the
IDBCursor interface returns the IDBObjectStore or
IDBIndex that the cursor is iterating over. This function never returns
null or throws an exception, even if the cursor is currently being iterated, has
iterated past its end, or its transaction is not active.

[Value("source")]
public Union107 Source { get; }

Property Value

Union107

The IDBObjectStore or IDBIndex that the cursor is
iterating over.

Remarks

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

Methods

Advance(ulong)

The advance() method of the IDBCursor
interface sets the number of times a cursor should move
its position forward.

[Value("advance")]
public GlobalObject.Undefined Advance(ulong count)

Parameters

count ulong

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

Continue(dynamic)

The continue() method of the IDBCursor
interface 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, the cursor
advances to the immediate next position, based on its direction.

[Value("continue")]
public GlobalObject.Undefined Continue(dynamic key = null)

Parameters

key dynamic

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

ContinuePrimaryKey(dynamic, dynamic)

The continuePrimaryKey() method of the
IDBCursor interface advances the cursor to the item whose key
matches the key parameter as well as whose primary key matches the primary key
parameter.

[Value("continuePrimaryKey")]
public GlobalObject.Undefined ContinuePrimaryKey(dynamic key, dynamic primaryKey)

Parameters

key dynamic
primaryKey dynamic

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

A typical use case, is to resume the iteration where a previous cursor has been closed,
without having to compare the keys one by one.

Calling this method more than once before new cursor data has been loaded - for
example, calling continuePrimaryKey() twice from the same onsuccess handler
- results in an InvalidStateError being thrown on the second call because
the cursor's got value flag has been unset.

This method is only valid for cursors coming from an index. Using it for cursors coming
from an object store will throw an error.

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

Delete()

The delete() method of the IDBCursor
interface returns an IDBRequest object, and, in a separate thread,
deletes the record at the cursor's position, without changing the cursor's position.
Once the record is deleted, the cursor's value is set to null.

[Value("delete")]
public IDBRequest Delete()

Returns

IDBRequest

An IDBRequest object on which subsequent events related to this
operation are fired.If the operation is successful, the value of the request's Result property is undefined.

Remarks

Be aware that you can't call delete() (or
Update(dynamic)) on cursors obtained from
OpenKeyCursor(dynamic, IDBCursorDirection). For such needs, you have to use
OpenCursor(dynamic, IDBCursorDirection) instead.

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN

Update(dynamic)

The update() method of the IDBCursor
interface returns an IDBRequest object, and, in a separate thread,
updates the value at the current position of the cursor in the object store. If the
cursor points to a record that has just been deleted, a new record is created.

[Value("update")]
public IDBRequest Update(dynamic value)

Parameters

value dynamic

Returns

IDBRequest

An IDBRequest object on which subsequent events related to this operation are fired.If the operation is successful, the value of the request's Result property is the key for the updated record.

Remarks

Be aware that you can't call update() (or
Delete()) on cursors obtained from
OpenKeyCursor(dynamic, IDBCursorDirection). For such needs, you have to use
OpenCursor(dynamic, IDBCursorDirection) instead.

-Using IndexedDB
-Starting transactions: IDBDatabase
-Using transactions: IDBTransaction
-Setting a range of keys: IDBKeyRange
-Retrieving and making changes to your data: IDBObjectStore
-Using cursors: IDBCursor
-Reference example: To-do Notifications (View the example live).

See also on MDN