public interface IDBTransaction extends EventTarget
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 are done within transactions. You actually use IDBDatabase
to start transactions and use IDBTransaction
to set the mode of the transaction and access an object store and make your request. You can also use it to abort transactions.
Inherits from: EventTarget
Modifier and Type | Field and Description |
---|---|
static int |
READ_ONLY
Allows data to be read but not changed.
|
static int |
READ_WRITE
Allows reading and writing of data in existing data stores to be changed.
|
static int |
VERSION_CHANGE
Allows any operation to be performed, including ones that delete and create object stores and indexes.
|
Modifier and Type | Method and Description |
---|---|
void |
abort()
Returns immediately, and undoes all the changes to objects in the database associated with this transaction.
|
EventRemover |
addEventListener(String type,
EventListener listener)
Register an event handler of a specific event type on the
EventTarget . |
EventRemover |
addEventListener(String type,
EventListener listener,
boolean useCapture)
Register an event handler of a specific event type on the
EventTarget . |
boolean |
dispatchEvent(Event evt)
Dispatch an event to this
EventTarget . |
IDBDatabase |
getDb()
The database connection that this transaction is associated with.
|
DOMError |
getError() |
String |
getMode()
The mode for isolating access to data in the object stores that are in the scope of the transaction.
|
EventListener |
getOnabort() |
EventListener |
getOncomplete() |
EventListener |
getOnerror() |
IDBObjectStore |
objectStore(String name)
Returns an object store that has already been added to the scope of this transaction.
|
void |
removeEventListener(String type,
EventListener listener)
Removes an event listener from the
EventTarget . |
void |
removeEventListener(String type,
EventListener listener,
boolean useCapture)
Removes an event listener from the
EventTarget . |
void |
setOnabort(EventListener arg) |
void |
setOncomplete(EventListener arg) |
void |
setOnerror(EventListener arg) |
static final int READ_ONLY
static final int READ_WRITE
static final int VERSION_CHANGE
setVersion()
method of IDBDatabase objects. Transactions of this mode cannot run concurrently with other transactions.IDBDatabase getDb()
DOMError getError()
String getMode()
READ_ONLY
.EventListener getOnabort()
void setOnabort(EventListener arg)
EventListener getOncomplete()
void setOncomplete(EventListener arg)
EventListener getOnerror()
void setOnerror(EventListener arg)
void abort()
Returns immediately, and undoes all the changes to objects in the database associated with this transaction. If this transaction has been aborted or completed, then this method throws an error event, with its code set to ABORT_ERR
and a suitable message.
All pending IDBRequest
objects created during this transaction have their errorCode
set to ABORT_ERR
.
This method can raise an IDBDatabaseException, with the following code:
NOT_ALLOWED_ERR
EventRemover addEventListener(String type, EventListener listener)
EventTarget
EventTarget
.addEventListener
in interface EventTarget
EventRemover addEventListener(String type, EventListener listener, boolean useCapture)
EventTarget
EventTarget
.addEventListener
in interface EventTarget
boolean dispatchEvent(Event evt)
EventTarget
EventTarget
.dispatchEvent
in interface EventTarget
IDBObjectStore objectStore(String name)
Returns an object store that has already been added to the scope of this transaction. Every call to this method on the same transaction object, with the same name, returns the same IDBObjectStore instance. If this method is called on a different transaction object, a different IDBObjectStore instance is returned.
IDBObjectStore
The method can raise an IDBDatabaseException with the following code:
NOT_FOUND_ERR
NOT_ALLOWED_ERR
void removeEventListener(String type, EventListener listener)
EventTarget
EventTarget
.removeEventListener
in interface EventTarget
void removeEventListener(String type, EventListener listener, boolean useCapture)
EventTarget
EventTarget
.removeEventListener
in interface EventTarget
Copyright © 2016. All rights reserved.