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

# Interface IDBDatabase

The **`IDBDatabase`** interface of the IndexedDB API provides a connection to a database; you can use an IDBDatabase object to open a transaction on your database then create, manipulate, and delete objects (data) in that database. The interface provides the only way to get and manage versions of the database.

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

interface IDBDatabase {  
    [name](#name): string;  
    [objectStoreNames](#objectstorenames): [DOMStringList](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.DOMStringList/);  
    [onabort](#onabort): ((this: IDBDatabase, ev: Event) \=> any) | null;  
    [onclose](#onclose): ((this: IDBDatabase, ev: Event) \=> any) | null;  
    [onerror](#onerror): ((this: IDBDatabase, ev: Event) \=> any) | null;  
    [onversionchange](#onversionchange):  
        | ((this: IDBDatabase, ev: [IDBVersionChangeEvent](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBVersionChangeEvent/)) \=> any)  
        | null;  
    [version](#version): number;  
    [addEventListener](#addeventlistener-1)<[K](#addeventlistenerk) extends keyof [IDBDatabaseEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBDatabaseEventMap/)\>(  
        type: [K](#addeventlistenerk),  
        listener: (this: IDBDatabase, ev: [IDBDatabaseEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBDatabaseEventMap/)\[[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;  
    [close](#close-1)(): void;  
    [createObjectStore](#createobjectstore-1)(  
        name: string,  
        options?: [IDBObjectStoreParameters](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBObjectStoreParameters/),  
    ): [IDBObjectStore](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBObjectStore/);  
    [deleteObjectStore](#deleteobjectstore-1)(name: string): void;  
    [dispatchEvent](#dispatchevent-1)(event: Event): boolean;  
    [removeEventListener](#removeeventlistener-1)<[K](#removeeventlistenerk) extends keyof [IDBDatabaseEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBDatabaseEventMap/)\>(  
        type: [K](#removeeventlistenerk),  
        listener: (this: IDBDatabase, ev: [IDBDatabaseEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBDatabaseEventMap/)\[[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;  
    [transaction](#transaction-1)(  
        storeNames: string | string\[\],  
        mode?: [IDBTransactionMode](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBTransactionMode/),  
        options?: [IDBTransactionOptions](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransactionOptions/),  
    ): [IDBTransaction](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransaction/);  
    [transaction](#transaction-2)(  
        storeNames: string | [Iterable](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.Iterable/)<string, any, any\>,  
        mode?: [IDBTransactionMode](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBTransactionMode/),  
        options?: [IDBTransactionOptions](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransactionOptions/),  
    ): [IDBTransaction](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransaction/);  
}

#### Hierarchy

-   EventTarget
    -   IDBDatabase

##### Index

### Properties[](#properties)

[name](#name) [objectStoreNames](#objectstorenames) [onabort](#onabort) [onclose](#onclose) [onerror](#onerror) [onversionchange](#onversionchange) [version](#version)

### Methods[](#methods)

[addEventListener](#addeventlistener) [close](#close) [createObjectStore](#createobjectstore) [deleteObjectStore](#deleteobjectstore) [dispatchEvent](#dispatchevent) [removeEventListener](#removeeventlistener) [transaction](#transaction)

## Properties[](#properties-1)

### `Readonly`name[](#name)

name: string

The **`name`** read-only property of the IDBDatabase interface is a string that contains the name of the connected database.

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

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

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

The **`objectStoreNames`** read-only property of the IDBDatabase interface is a DOMStringList containing a list of the names of the object stores currently in the connected database.

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

### onabort[](#onabort)

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

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

### onclose[](#onclose)

onclose: ((this: IDBDatabase, ev: Event) \=> any) | null

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

### onerror[](#onerror)

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

### onversionchange[](#onversionchange)

onversionchange: ((this: IDBDatabase, ev: [IDBVersionChangeEvent](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBVersionChangeEvent/)) \=> any) | null

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

### `Readonly`version[](#version)

version: number

The **`version`** property of the IDBDatabase interface is a 64-bit integer that contains the version of the connected database. When a database is first created, this attribute is an empty string.

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

## Methods[](#methods-1)

### addEventListener[](#addeventlistener)

-   addEventListener<[K](#addeventlistenerk) extends keyof [IDBDatabaseEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBDatabaseEventMap/)\>(  
        type: [K](#addeventlistenerk),  
        listener: (this: IDBDatabase, ev: [IDBDatabaseEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBDatabaseEventMap/)\[[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 [IDBDatabaseEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBDatabaseEventMap/)
    
    #### Parameters
    
    -   type: [K](#addeventlistenerk)
    -   listener: (this: IDBDatabase, ev: [IDBDatabaseEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBDatabaseEventMap/)\[[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
    

### close[](#close)

-   close(): void[](#close-1)
    
    The **`close()`** method of the IDBDatabase interface returns immediately and closes the connection in a separate thread.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBDatabase/close)
    
    #### Returns void
    

### createObjectStore[](#createobjectstore)

-   createObjectStore(  
        name: string,  
        options?: [IDBObjectStoreParameters](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBObjectStoreParameters/),  
    ): [IDBObjectStore](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBObjectStore/)[](#createobjectstore-1)
    
    The **`createObjectStore()`** method of the IDBDatabase interface creates and returns a new IDBObjectStore.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBDatabase/createObjectStore)
    
    #### Parameters
    
    -   name: string
    -   `Optional`options: [IDBObjectStoreParameters](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBObjectStoreParameters/)
    
    #### Returns [IDBObjectStore](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBObjectStore/)
    

### deleteObjectStore[](#deleteobjectstore)

-   deleteObjectStore(name: string): void[](#deleteobjectstore-1)
    
    The **`deleteObjectStore()`** method of the IDBDatabase interface destroys the object store with the given name in the connected database, along with any indexes that reference it.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBDatabase/deleteObjectStore)
    
    #### Parameters
    
    -   name: string
    
    #### 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
    

### removeEventListener[](#removeeventlistener)

-   removeEventListener<[K](#removeeventlistenerk) extends keyof [IDBDatabaseEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBDatabaseEventMap/)\>(  
        type: [K](#removeeventlistenerk),  
        listener: (this: IDBDatabase, ev: [IDBDatabaseEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBDatabaseEventMap/)\[[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 [IDBDatabaseEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBDatabaseEventMap/)
    
    #### Parameters
    
    -   type: [K](#removeeventlistenerk)
    -   listener: (this: IDBDatabase, ev: [IDBDatabaseEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBDatabaseEventMap/)\[[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
    

### transaction[](#transaction)

-   transaction(  
        storeNames: string | string\[\],  
        mode?: [IDBTransactionMode](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBTransactionMode/),  
        options?: [IDBTransactionOptions](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransactionOptions/),  
    ): [IDBTransaction](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransaction/)[](#transaction-1)
    
    The **`transaction`** method of the IDBDatabase interface immediately returns a transaction object (IDBTransaction) containing the IDBTransaction.objectStore method, which you can use to access your object store.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBDatabase/transaction)
    
    #### Parameters
    
    -   storeNames: string | string\[\]
    -   `Optional`mode: [IDBTransactionMode](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBTransactionMode/)
    -   `Optional`options: [IDBTransactionOptions](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransactionOptions/)
    
    #### Returns [IDBTransaction](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransaction/)
    
-   transaction(  
        storeNames: string | [Iterable](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.Iterable/)<string, any, any\>,  
        mode?: [IDBTransactionMode](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBTransactionMode/),  
        options?: [IDBTransactionOptions](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransactionOptions/),  
    ): [IDBTransaction](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransaction/)[](#transaction-2)
    
    The **`transaction`** method of the IDBDatabase interface immediately returns a transaction object (IDBTransaction) containing the IDBTransaction.objectStore method, which you can use to access your object store.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBDatabase/transaction)
    
    #### Parameters
    
    -   storeNames: string | [Iterable](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.Iterable/)<string, any, any\>
    -   `Optional`mode: [IDBTransactionMode](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBTransactionMode/)
    -   `Optional`options: [IDBTransactionOptions](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransactionOptions/)
    
    #### Returns [IDBTransaction](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBTransaction/)
