Join us online - 19th of November
Save your spot
For AI agents: a documentation index is available at /llms.txt. Markdown versions of all pages are available by appending .md to any URL.

Interface IDBTransaction

The IDBTransaction interface of the IndexedDB API provides a static, asynchronous transaction on a database using event handler attributes. All reading and writing of data is done within transactions. You use IDBDatabase to start transactions, IDBTransaction to set the mode of the transaction (e.g., is it readonly or readwrite), and you access an IDBObjectStore to make a request. You can also use an IDBTransaction object to abort transactions.

MDN Reference

interface IDBTransaction {
    db: IDBDatabase;
    durability: IDBTransactionDurability;
    error: DOMException | null;
    mode: IDBTransactionMode;
    objectStoreNames: DOMStringList;
    onabort: ((this: IDBTransaction, ev: Event) => any) | null;
    oncomplete: ((this: IDBTransaction, ev: Event) => any) | null;
    onerror: ((this: IDBTransaction, ev: Event) => any) | null;
    abort(): void;
    addEventListener<K extends keyof IDBTransactionEventMap>(
        type: K,
        listener: (this: IDBTransaction, ev: IDBTransactionEventMap[K]) => any,
        options?: boolean | AddEventListenerOptions,
    ): void;
    addEventListener(
        type: string,
        listener: EventListenerOrEventListenerObject,
        options?: boolean | AddEventListenerOptions,
    ): void;
    commit(): void;
    dispatchEvent(event: Event): boolean;
    objectStore(name: string): IDBObjectStore;
    removeEventListener<K extends keyof IDBTransactionEventMap>(
        type: K,
        listener: (this: IDBTransaction, ev: IDBTransactionEventMap[K]) => any,
        options?: boolean | EventListenerOptions,
    ): void;
    removeEventListener(
        type: string,
        listener: EventListenerOrEventListenerObject,
        options?: boolean | EventListenerOptions,
    ): void;
}

Hierarchy

  • EventTarget
    • IDBTransaction
Index

The db read-only property of the IDBTransaction interface returns the database connection with which this transaction is associated.

MDN Reference

The durability read-only property of the IDBTransaction interface returns the durability hint the transaction was created with. This is a hint to the user agent of whether to prioritize performance or durability when committing the transaction.

MDN Reference

error: DOMException | null

The IDBTransaction.error property of the IDBTransaction interface returns the type of error when there is an unsuccessful transaction.

MDN Reference

The mode read-only property of the IDBTransaction interface returns the current mode for accessing the data in the object stores in the scope of the transaction (i.e., is the mode to be read-only, or do you want to write to the object stores?) The default value is readonly.

MDN Reference

objectStoreNames: DOMStringList

The objectStoreNames read-only property of the IDBTransaction interface returns a DOMStringList of names of IDBObjectStore objects.

MDN Reference

onabort: ((this: IDBTransaction, ev: Event) => any) | null
oncomplete: ((this: IDBTransaction, ev: Event) => any) | null
onerror: ((this: IDBTransaction, ev: Event) => any) | null
  • The abort() method of the IDBTransaction interface rolls back all the changes to objects in the database associated with this transaction.

    MDN Reference

    Returns void

  • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

    MDN Reference

    Type Parameters

    Parameters

    Returns void

  • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

    MDN Reference

    Parameters

    Returns void

  • The commit() method of the IDBTransaction interface commits the transaction if it is called on an active transaction.

    MDN Reference

    Returns void

  • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().

    MDN Reference

    Parameters

    • event: Event

    Returns boolean

  • The objectStore() method of the IDBTransaction interface returns an object store that has already been added to the scope of this transaction.

    MDN Reference

    Parameters

    • name: string

    Returns IDBObjectStore

  • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.

    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. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.

    MDN Reference

    Parameters

    Returns void

Was this helpful?