---
title: "IDBTransaction | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/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](https://developer.mozilla.org/docs/Web/API/IDBTransaction)

interface IDBTransaction {  
    [db](#db): [IDBDatabase](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBDatabase/);  
    [durability](#durability): [IDBTransactionDurability](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBTransactionDurability/);  
    [error](#error): DOMException | null;  
    [mode](#mode): [IDBTransactionMode](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBTransactionMode/);  
    [objectStoreNames](#objectstorenames): [DOMStringList](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.DOMStringList/);  
    [onabort](#onabort): ((this: IDBTransaction, ev: Event) \=> any) | null;  
    [oncomplete](#oncomplete): ((this: IDBTransaction, ev: Event) \=> any) | null;  
    [onerror](#onerror): ((this: IDBTransaction, ev: Event) \=> any) | null;  
    [abort](#abort-1)(): void;  
    [addEventListener](#addeventlistener-1)<[K](#addeventlistenerk) extends keyof [IDBTransactionEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransactionEventMap/)\>(  
        type: [K](#addeventlistenerk),  
        listener: (this: IDBTransaction, ev: [IDBTransactionEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransactionEventMap/)\[[K](#addeventlistenerk)\]) \=> any,  
        options?: boolean | AddEventListenerOptions,  
    ): void;  
    [addEventListener](#addeventlistener-2)(  
        type: string,  
        listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/),  
        options?: boolean | AddEventListenerOptions,  
    ): void;  
    [commit](#commit-1)(): void;  
    [dispatchEvent](#dispatchevent-1)(event: Event): boolean;  
    [objectStore](#objectstore-1)(name: string): [IDBObjectStore](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBObjectStore/);  
    [removeEventListener](#removeeventlistener-1)<[K](#removeeventlistenerk) extends keyof [IDBTransactionEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransactionEventMap/)\>(  
        type: [K](#removeeventlistenerk),  
        listener: (this: IDBTransaction, ev: [IDBTransactionEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransactionEventMap/)\[[K](#removeeventlistenerk)\]) \=> any,  
        options?: boolean | EventListenerOptions,  
    ): void;  
    [removeEventListener](#removeeventlistener-2)(  
        type: string,  
        listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/),  
        options?: boolean | EventListenerOptions,  
    ): void;  
}

#### Hierarchy

-   EventTarget
    -   IDBTransaction

##### Index

### Properties[](#properties)

[db](#db) [durability](#durability) [error](#error) [mode](#mode) [objectStoreNames](#objectstorenames) [onabort](#onabort) [oncomplete](#oncomplete) [onerror](#onerror)

### Methods[](#methods)

[abort](#abort) [addEventListener](#addeventlistener) [commit](#commit) [dispatchEvent](#dispatchevent) [objectStore](#objectstore) [removeEventListener](#removeeventlistener)

## Properties[](#properties-1)

### `Readonly`db[](#db)

db: [IDBDatabase](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBDatabase/)

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

[MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBTransaction/db)

### `Readonly`durability[](#durability)

durability: [IDBTransactionDurability](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBTransactionDurability/)

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](https://developer.mozilla.org/docs/Web/API/IDBTransaction/durability)

### `Readonly`error[](#error)

error: DOMException | null

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

[MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBTransaction/error)

### `Readonly`mode[](#mode)

mode: [IDBTransactionMode](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBTransactionMode/)

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](https://developer.mozilla.org/docs/Web/API/IDBTransaction/mode)

### `Readonly`objectStoreNames[](#objectstorenames)

objectStoreNames: [DOMStringList](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.DOMStringList/)

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

[MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBTransaction/objectStoreNames)

### onabort[](#onabort)

onabort: ((this: IDBTransaction, ev: Event) \=> any) | null

[MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBTransaction/abort_event)

### oncomplete[](#oncomplete)

oncomplete: ((this: IDBTransaction, ev: Event) \=> any) | null

[MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBTransaction/complete_event)

### onerror[](#onerror)

onerror: ((this: IDBTransaction, ev: Event) \=> any) | null

[MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBTransaction/error_event)

## Methods[](#methods-1)

### abort[](#abort)

-   abort(): void[](#abort-1)
    
    The **`abort()`** method of the IDBTransaction interface rolls back all the changes to objects in the database associated with this transaction.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBTransaction/abort)
    
    #### Returns void
    

### addEventListener[](#addeventlistener)

-   addEventListener<[K](#addeventlistenerk) extends keyof [IDBTransactionEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransactionEventMap/)\>(  
        type: [K](#addeventlistenerk),  
        listener: (this: IDBTransaction, ev: [IDBTransactionEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransactionEventMap/)\[[K](#addeventlistenerk)\]) \=> any,  
        options?: boolean | AddEventListenerOptions,  
    ): void[](#addeventlistener-1)
    
    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](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
    
    #### Type Parameters
    
    -   K extends keyof [IDBTransactionEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransactionEventMap/)
    
    #### Parameters
    
    -   type: [K](#addeventlistenerk)
    -   listener: (this: IDBTransaction, ev: [IDBTransactionEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransactionEventMap/)\[[K](#addeventlistenerk)\]) \=> any
    -   `Optional`options: boolean | AddEventListenerOptions
    
    #### Returns void
    
    Overrides EventTarget.addEventListener
    
-   addEventListener(  
        type: string,  
        listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/),  
        options?: boolean | AddEventListenerOptions,  
    ): void[](#addeventlistener-2)
    
    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](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
    
    #### Parameters
    
    -   type: string
    -   listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/)
    -   `Optional`options: boolean | AddEventListenerOptions
    
    #### Returns void
    
    Overrides EventTarget.addEventListener
    

### commit[](#commit)

-   commit(): void[](#commit-1)
    
    The **`commit()`** method of the IDBTransaction interface commits the transaction if it is called on an active transaction.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBTransaction/commit)
    
    #### Returns void
    

### dispatchEvent[](#dispatchevent)

-   dispatchEvent(event: Event): boolean[](#dispatchevent-1)
    
    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](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
    
    #### Parameters
    
    -   event: Event
    
    #### Returns boolean
    
    Inherited from EventTarget.dispatchEvent
    

### objectStore[](#objectstore)

-   objectStore(name: string): [IDBObjectStore](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBObjectStore/)[](#objectstore-1)
    
    The **`objectStore()`** method of the IDBTransaction interface returns an object store that has already been added to the scope of this transaction.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBTransaction/objectStore)
    
    #### Parameters
    
    -   name: string
    
    #### Returns [IDBObjectStore](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBObjectStore/)
    

### removeEventListener[](#removeeventlistener)

-   removeEventListener<[K](#removeeventlistenerk) extends keyof [IDBTransactionEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransactionEventMap/)\>(  
        type: [K](#removeeventlistenerk),  
        listener: (this: IDBTransaction, ev: [IDBTransactionEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransactionEventMap/)\[[K](#removeeventlistenerk)\]) \=> any,  
        options?: boolean | EventListenerOptions,  
    ): void[](#removeeventlistener-1)
    
    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](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
    
    #### Type Parameters
    
    -   K extends keyof [IDBTransactionEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransactionEventMap/)
    
    #### Parameters
    
    -   type: [K](#removeeventlistenerk)
    -   listener: (this: IDBTransaction, ev: [IDBTransactionEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransactionEventMap/)\[[K](#removeeventlistenerk)\]) \=> any
    -   `Optional`options: boolean | EventListenerOptions
    
    #### Returns void
    
    Overrides EventTarget.removeEventListener
    
-   removeEventListener(  
        type: string,  
        listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/),  
        options?: boolean | EventListenerOptions,  
    ): void[](#removeeventlistener-2)
    
    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](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
    
    #### Parameters
    
    -   type: string
    -   listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/)
    -   `Optional`options: boolean | EventListenerOptions
    
    #### Returns void
    
    Overrides EventTarget.removeEventListener
