Table of Contents

Class IDBRequest

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The IDBRequest interface of the IndexedDB API provides access to results of asynchronous requests to databases and database objects using event handler attributes. Each reading and writing operation on a database is done using a request.

[Value("IDBRequest")]
public class IDBRequest : EventTarget
Inheritance
IDBRequest
Derived
Inherited Members

Remarks

The request object does not initially contain any information about the result of the operation, but once information becomes available, an event is fired on the request, and the information becomes available through the properties of the IDBRequest instance.

All asynchronous operations immediately return an IDBRequest instance. Each request has a readyState that is set to the 'pending' state; this changes to 'done' when the request is completed or fails. When the state is set to done, every request returns a result and an error, and an event is fired on the request. When the state is still pending, any attempt to access the result or error raises an InvalidStateError exception.

In plain words, all asynchronous methods return a request object. If the request has been completed successfully, the result is made available through the result property and an event indicating success is fired at the request (IDBRequest.Success). If an error occurs while performing the operation, the exception is made available through the error property and an error event is fired (Error).

The interface IDBOpenDBRequest is derived from IDBRequest.

-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

Constructors

IDBRequest()

public IDBRequest()

Properties

Error

The error read-only property of the
IDBRequest interface returns the error in the event of an unsuccessful
request.

[Value("error")]
public DOMException? Error { get; }

Property Value

DOMException

A DOMException or null if there is no error. The exception object will have one of the following names, depending on what caused the error.These errors are asynchronous, meaning that they can't be handled via try...catch. However, if an IDBRequest has an Error event handler assigned, you can still inspect such errors by querying the request's error property via the event object, for example event.target.error.name or event.target.error.message.

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

Onerror

[Value("onerror")]
public EventHandlerNonNull Onerror { get; set; }

Property Value

EventHandlerNonNull

Onsuccess

[Value("onsuccess")]
public EventHandlerNonNull Onsuccess { get; set; }

Property Value

EventHandlerNonNull

ReadyState

The readyState read-only property of the
IDBRequest interface returns the state of the request.

[Value("readyState")]
public IDBRequestReadyState ReadyState { get; }

Property Value

IDBRequestReadyState

One of the following strings:

Remarks

Every request starts in the pending state. The state changes to
done when the request completes successfully or when an error
occurs.

-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

Result

The result read-only property of the
IDBRequest interface returns the result of the request.

[Value("result")]
public dynamic Result { get; }

Property Value

dynamic

any

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
IDBRequest interface returns the source of the request, such as an
Index or an object store. If no source exists (such as when calling
Open(string, ulong)), it returns null.

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

Property Value

Union103?

An object representing the source of the request, such as an IDBIndex,
IDBObjectStore or IDBCursor.

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

Transaction

The transaction read-only property of the IDBRequest
interface returns the transaction for the request, that is, the transaction the
request is being made inside.

[Value("transaction")]
public IDBTransaction? Transaction { get; }

Property Value

IDBTransaction

An IDBTransaction.

Remarks

This property can be null for requests not made within transactions,
such as for requests returned from Open(string, ulong) — in this case
you're just connecting to a database, so there is no transaction to return. If a
version upgrade is needed when opening a database then during the
IDBOpenDBRequest.Upgradeneeded event handler the
transaction property will be an
IDBTransaction with Mode equal
to "versionchange", and can be used to access existing object stores and
indexes, or abort the upgrade. Following the upgrade, the
transaction property will again be null.

-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