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.

Documentation IDBDatabase by Mozilla Contributors, licensed under CC-BY-SA 2.5.

See also:

Variables

read onlyname:String

A DOMString that contains the name of the connected database.

read onlyobjectStoreNames:DOMStringList

A DOMStringList that contains a list of the names of the object stores currently in the connected database.

onabort:Function

Fires when access of the database is aborted.

onclose:Function

Fires when the close event occurs; this happens when the database is unexpectedly closed, such as during application shutdown.

onerror:Function

Fires when access to the database fails.

onversionchange:Function

Fires when a database structure change (IDBOpenDBRequest.onupgradeneeded event or IDBFactory.deleteDatabase() was requested elsewhere (most probably in another window/tab on the same computer). This is different from the version change transaction (see IDBVersionChangeEvent), but it is related.

read onlyversion:Int

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

close():Void

Returns immediately and closes the connection to a database in a separate thread.

createMutableFile(name:String, ?type:String):Request

Throws:

null

DOMError

createObjectStore(name:String, ?optionalParameters:Null<ObjectStoreParameters>):ObjectStore

Creates and returns a new object store or index.

Throws:

null

DOMError

deleteObjectStore(name:String):Void

Destroys the object store with the given name in the connected database, along with any indexes that reference it.

Throws:

null

DOMError

@:value({ mode : READONLY })transaction(storeNames:String, mode:TransactionMode = READONLY):Transaction

@:value({ mode : READONLY })transaction(storeNames:Array<String>, mode:TransactionMode = READONLY):Transaction

Immediately returns a transaction object (IDBTransaction) containing the IDBTransaction.objectStore method, which you can use to access your object store. Runs in a separate thread.

Throws:

null

DOMError

Inherited Variables

Inherited Methods

Defined by EventTarget

addEventListener(type:String, listener:Function, ?options:EitherType<AddEventListenerOptions, Bool>, ?wantsUntrusted:Bool):Void

addEventListener(type:String, listener:EventListener, ?options:EitherType<AddEventListenerOptions, Bool>, ?wantsUntrusted:Bool):Void

Register an event handler of a specific event type on the EventTarget.

Throws:

null

DOMError

dispatchEvent(event:Event):Bool

Dispatch an event to this EventTarget.

Throws:

null

DOMError

removeEventListener(type:String, listener:Function, ?options:EitherType<EventListenerOptions, Bool>):Void

removeEventListener(type:String, listener:EventListener, ?options:EitherType<EventListenerOptions, Bool>):Void

Removes an event listener from the EventTarget.

Throws:

null

DOMError