Interface IDBDatabase
name: string;
objectStoreNames: DOMStringList;
onabort: ((this: IDBDatabase, ev: Event) => any) | null;
onclose: ((this: IDBDatabase, ev: Event) => any) | null;
onerror: ((this: IDBDatabase, ev: Event) => any) | null;
onversionchange:
| ((this: IDBDatabase, ev: IDBVersionChangeEvent) => any)
| null;
version: number;
addEventListener<K extends keyof IDBDatabaseEventMap>(
type: K,
listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void;
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void;
close(): void;
createObjectStore(
name: string,
options?: IDBObjectStoreParameters,
): IDBObjectStore;
deleteObjectStore(name: string): void;
dispatchEvent(event: Event): boolean;
removeEventListener<K extends keyof IDBDatabaseEventMap>(
type: K,
listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void;
removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void;
transaction(
storeNames: string | string[],
mode?: IDBTransactionMode,
options?: IDBTransactionOptions,
): IDBTransaction;
transaction(
storeNames: string | Iterable<string, any, any>,
mode?: IDBTransactionMode,
options?: IDBTransactionOptions,
): IDBTransaction;
}
Hierarchy
- EventTarget
- IDBDatabase
Properties
Readonlyname
The name read-only property of the IDBDatabase interface is a string that contains the name of the connected database.
ReadonlyobjectStoreNames
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.
onabort
onclose
onerror
onversionchange
Readonlyversion
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.
Methods
addEventListener
-
addEventListener<K extends keyof IDBDatabaseEventMap>(
type: K,
listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): voidThe
addEventListener()method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.Type Parameters
- K extends keyof IDBDatabaseEventMap
Parameters
- type: K
- listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any
Optionaloptions: boolean | AddEventListenerOptions
Returns void
-
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): voidThe
addEventListener()method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.Parameters
- type: string
- listener: EventListenerOrEventListenerObject
Optionaloptions: boolean | AddEventListenerOptions
Returns void
close
-
The
close()method of the IDBDatabase interface returns immediately and closes the connection in a separate thread.Returns void
createObjectStore
-
The
createObjectStore()method of the IDBDatabase interface creates and returns a new IDBObjectStore.Parameters
- name: string
Optionaloptions: IDBObjectStoreParameters
Returns IDBObjectStore
deleteObjectStore
-
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.Parameters
- name: string
Returns void
dispatchEvent
-
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().Parameters
- event: Event
Returns boolean
removeEventListener
-
removeEventListener<K extends keyof IDBDatabaseEventMap>(
type: K,
listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): voidThe
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.Type Parameters
- K extends keyof IDBDatabaseEventMap
Parameters
- type: K
- listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any
Optionaloptions: boolean | EventListenerOptions
Returns void
-
removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): voidThe
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.Parameters
- type: string
- listener: EventListenerOrEventListenerObject
Optionaloptions: boolean | EventListenerOptions
Returns void
transaction
-
transaction(
storeNames: string | string[],
mode?: IDBTransactionMode,
options?: IDBTransactionOptions,
): IDBTransactionThe
transactionmethod of the IDBDatabase interface immediately returns a transaction object (IDBTransaction) containing the IDBTransaction.objectStore method, which you can use to access your object store.Parameters
- storeNames: string | string[]
Optionalmode: IDBTransactionModeOptionaloptions: IDBTransactionOptions
Returns IDBTransaction
-
transaction(
storeNames: string | Iterable<string, any, any>,
mode?: IDBTransactionMode,
options?: IDBTransactionOptions,
): IDBTransactionThe
transactionmethod of the IDBDatabase interface immediately returns a transaction object (IDBTransaction) containing the IDBTransaction.objectStore method, which you can use to access your object store.Parameters
- storeNames: string | Iterable<string, any, any>
Optionalmode: IDBTransactionModeOptionaloptions: IDBTransactionOptions
Returns IDBTransaction
The
IDBDatabaseinterface 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