pub struct Transaction { /* private fields */ }Expand description
Provides a transaction on a database. All reading and writing of data is done within transactions.
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub fn builder(database: &Database) -> TransactionBuilder<'_>
pub fn builder(database: &Database) -> TransactionBuilder<'_>
Creates a new TransactionBuilder with the given database.
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 object_store<M>(&self) -> Result<ObjectStore<'_, M>, Error>where
M: Model,
pub fn object_store<M>(&self) -> Result<ObjectStore<'_, M>, Error>where
M: Model,
Returns an ObjectStore for a model in transaction’s scope.
Sourcepub async fn commit(self) -> Result<TransactionResult, Error>
pub async fn commit(self) -> Result<TransactionResult, 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 async fn abort(self) -> Result<TransactionResult, Error>
pub async fn abort(self) -> Result<TransactionResult, Error>
Aborts the transaction. All pending requests will fail and all changes made to the database will be reverted.
Sourcepub async fn done(self) -> Result<TransactionResult, Error>
pub async fn done(self) -> Result<TransactionResult, Error>
Waits for the transaction to complete and returns the result.