Struct idb::Transaction
source · 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 async fn commit(self) -> Result<(), Error>
pub async fn commit(self) -> Result<(), 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.