IDBDatabase

@native @JSGlobal @JSType
class IDBDatabase extends EventTarget

The IDBDatabase interface of the IndexedDB API provides asynchronous access to a connection to a database. Use it to create, manipulate, and delete objects in that database. The interface also provides the only way to get a transaction and manage versions on that database.

Everything you do in IndexedDB always happens in the context of a transaction, representing interactions with data in the database. All objects in IndexedDB—including object stores, indexes, and cursors—are tied to a particular transaction. Thus, you cannot execute commands, access data, or open anything outside of a transaction.

class Object
trait Any
class Object
trait Matchable
class Any

Value members

Concrete methods

def close(): Unit

The connection is not actually closed until all transactions created using this connection are complete. No new transactions can be created for this connection once this method is called. Methods that create transactions throw an exception if a closing operation is pending.

The connection is not actually closed until all transactions created using this connection are complete. No new transactions can be created for this connection once this method is called. Methods that create transactions throw an exception if a closing operation is pending.

def createObjectStore(name: String, optionalParameters: UndefOr[IDBCreateObjectStoreOptions]): IDBObjectStore

The method takes the name of the store as well as a parameter object. The parameter object lets you define important optional properties. You can use the property to uniquely identify individual objects in the store. As the property is an identifier, it should be unique to every object, and every object should have that property.

The method takes the name of the store as well as a parameter object. The parameter object lets you define important optional properties. You can use the property to uniquely identify individual objects in the store. As the property is an identifier, it should be unique to every object, and every object should have that property.

def deleteObjectStore(name: String): Unit

As with createObjectStore, this method can be called only within a versionchange transaction. So for WebKit browsers you must call the IDBVersionChangeRequest.setVersion method first before you can remove any object store or index.

As with createObjectStore, this method can be called only within a versionchange transaction. So for WebKit browsers you must call the IDBVersionChangeRequest.setVersion method first before you can remove any object store or index.

def name: String

A DOMString that contains the name of the connected database.

A DOMString that contains the name of the connected database.

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

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

def transaction(storeNames: String | Array[String], mode: UndefOr[IDBTransactionMode], options: UndefOr[IDBTransactionOptions]): IDBTransaction

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.

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.

def version: Double

A 64-bit integer that contains the version of the connected database. When a database is first created or upgraded you should use IDBVersionChangeEvent#newVersion instead. Webkit returns always integer and the value is 1 when database is first created.

A 64-bit integer that contains the version of the connected database. When a database is first created or upgraded you should use IDBVersionChangeEvent#newVersion instead. Webkit returns always integer and the value is 1 when database is first created.

Inherited methods

def addEventListener[T <: Event](`type`: String, listener: Function1[T, _], options: EventListenerOptions): Unit

The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events (such as XMLHttpRequest).

The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events (such as XMLHttpRequest).

This implementation accepts a settings object of type EventListenerOptions.

Inherited from:
EventTarget
def addEventListener[T <: Event](`type`: String, listener: Function1[T, _], useCapture: Boolean): Unit

The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events (such as XMLHttpRequest).

The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events (such as XMLHttpRequest).

Inherited from:
EventTarget
def dispatchEvent(evt: Event): Boolean

Dispatches an Event at the specified EventTarget, invoking the affected EventListeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) apply to events dispatched manually with dispatchEvent().

Dispatches an Event at the specified EventTarget, invoking the affected EventListeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) apply to events dispatched manually with dispatchEvent().

Inherited from:
EventTarget
def hasOwnProperty(v: String): Boolean
Inherited from:
Object
def isPrototypeOf(v: Object): Boolean
Inherited from:
Object
def propertyIsEnumerable(v: String): Boolean
Inherited from:
Object
def removeEventListener[T <: Event](`type`: String, listener: Function1[T, _], options: EventListenerOptions): Unit

Removes the event listener previously registered with EventTarget.addEventListener.

Removes the event listener previously registered with EventTarget.addEventListener.

This implementation accepts a settings object of type EventListenerOptions.

Inherited from:
EventTarget
def removeEventListener[T <: Event](`type`: String, listener: Function1[T, _], useCapture: Boolean): Unit

Removes the event listener previously registered with EventTarget.addEventListener.

Removes the event listener previously registered with EventTarget.addEventListener.

Inherited from:
EventTarget
def toLocaleString(): String
Inherited from:
Object
def valueOf(): Any
Inherited from:
Object

Concrete fields

var onabort: Function1[Event, _]

Fires when access of the database is aborted.

Fires when access of the database is aborted.

var onclose: Function1[CloseEvent, _]

The onclose event handler of the IDBDatabase interface handles the close event, which is fired when the database is unexpectedly closed. This can happen, for example, when the application is shut down or access to the disk the database is stored on is lost while the database is open.

The onclose event handler of the IDBDatabase interface handles the close event, which is fired when the database is unexpectedly closed. This can happen, for example, when the application is shut down or access to the disk the database is stored on is lost while the database is open.

The close event is fired after all transactions have been aborted and the connection has been closed.

var onerror: Function1[ErrorEvent, _]

Fires when access to the database fails.

Fires when access to the database fails.

The onversionchange event handler of the IDBDatabase interface handles the versionchange event, fired when a database structure change (IDBOpenDBRequest.onupgradeneeded event or IDBFactory.deleteDatabase) was requested elsewhere (most probably in another window/tab on the same computer).

The onversionchange event handler of the IDBDatabase interface handles the versionchange event, fired when a database structure change (IDBOpenDBRequest.onupgradeneeded event or IDBFactory.deleteDatabase) was requested elsewhere (most probably in another window/tab on the same computer).