pub struct Transaction { /* private fields */ }
Expand description
Provides a static, asynchronous transaction on a database. All reading and writing of data is done within transactions.
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub fn store_names(&self) -> Vec<String>
pub fn store_names(&self) -> Vec<String>
Returns a list of the names of object stores in the transaction’s scope. For an upgrade transaction this is all object stores in the database.
Sourcepub fn mode(&self) -> Result<TransactionMode, Error>
pub fn mode(&self) -> Result<TransactionMode, Error>
Returns the mode the transaction was created with (“readonly” or “readwrite”), or “versionchange” for an upgrade transaction.
Sourcepub fn error(&self) -> Option<DomException>
pub fn error(&self) -> Option<DomException>
If the transaction was aborted, returns the error (a DOMException
) providing the reason.
Sourcepub fn object_store(&self, name: &str) -> Result<ObjectStore, Error>
pub fn object_store(&self, name: &str) -> Result<ObjectStore, Error>
Returns an ObjectStore
in the transaction’s scope.
Sourcepub fn commit(self) -> Result<Self, Error>
pub fn commit(self) -> Result<Self, Error>
Attempts to commit the transaction. All pending requests will be allowed to complete, but no new requests will be accepted. This can be used to force a transaction to quickly finish, without waiting for pending requests to fire success events before attempting to commit normally.
Sourcepub fn abort(self) -> Result<Self, Error>
pub fn abort(self) -> Result<Self, Error>
Aborts the transaction. All pending requests will fail and all changes made to the database will be reverted.
Sourcepub fn on_complete<F>(&mut self, callback: F)
pub fn on_complete<F>(&mut self, callback: F)
Adds an event handler for complete
event.
Sourcepub fn forget_callbacks(&mut self)
pub fn forget_callbacks(&mut self)
Release memory management of the callbacks to JS GC.
Note: This may leak memory. Read more about it here.