The IDBRequest interface of the IndexedDB API provides access to results of asynchronous requests to databases and database objects using event handler attributes.

MDN Reference

interface IDBRequest<T = any> {
    error: DOMException | null;
    onerror: ((this: IDBRequest<T>, ev: Event) => any) | null;
    onsuccess: ((this: IDBRequest<T>, ev: Event) => any) | null;
    readyState: IDBRequestReadyState;
    result: T;
    source: IDBObjectStore | IDBIndex | IDBCursor;
    transaction: IDBTransaction | null;
    addEventListener<K extends keyof IDBRequestEventMap>(
        type: K,
        listener: (this: IDBRequest<T>, ev: IDBRequestEventMap[K]) => any,
        options?: boolean | AddEventListenerOptions,
    ): void;
    addEventListener(
        type: string,
        listener: EventListenerOrEventListenerObject,
        options?: boolean | AddEventListenerOptions,
    ): void;
    dispatchEvent(event: Event): boolean;
    removeEventListener<K extends keyof IDBRequestEventMap>(
        type: K,
        listener: (this: IDBRequest<T>, ev: IDBRequestEventMap[K]) => any,
        options?: boolean | EventListenerOptions,
    ): void;
    removeEventListener(
        type: string,
        listener: EventListenerOrEventListenerObject,
        options?: boolean | EventListenerOptions,
    ): void;
}

Type Parameters

  • T = any
Hierarchy
Index

Properties

error: DOMException | null

The error read-only property of the request.

MDN Reference

onerror: ((this: IDBRequest<T>, ev: Event) => any) | null
onsuccess: ((this: IDBRequest<T>, ev: Event) => any) | null

The readyState read-only property of the Every request starts in the pending state.

MDN Reference

result: T

The result read-only property of the any - InvalidStateError DOMException - : Thrown when attempting to access the property if the request is not completed, and therefore the result is not available.

MDN Reference

source: IDBObjectStore | IDBIndex | IDBCursor

The source read-only property of the Index or an object store.

MDN Reference

transaction: IDBTransaction | null

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.

MDN Reference

Methods

  • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.

    MDN Reference

    Parameters

    • event: Event

    Returns boolean

  • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.

    MDN Reference

    Type Parameters

    Parameters

    Returns void

  • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.

    MDN Reference

    Parameters

    Returns void