Skip to main content

TransactionTrait

Trait TransactionTrait 

Source
pub trait TransactionTrait: Sync {
    type Transaction: ConnectionTrait + TransactionTrait<Transaction = Self::Transaction> + TransactionSession + Send;

    // Required methods
    fn begin<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Transaction, DbErr>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn begin_with_config<'life0, 'async_trait>(
        &'life0 self,
        isolation_level: Option<IsolationLevel>,
        access_mode: Option<AccessMode>,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Transaction, DbErr>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn begin_with_options<'life0, 'async_trait>(
        &'life0 self,
        options: TransactionOptions,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Transaction, DbErr>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn transaction<'life0, 'async_trait, F, T, E>(
        &'life0 self,
        callback: F,
    ) -> Pin<Box<dyn Future<Output = Result<T, TransactionError<E>>> + Send + 'async_trait>>
       where F: for<'c> FnOnce(&'c Self::Transaction) -> Pin<Box<dyn Future<Output = Result<T, E>> + Send + 'c>> + Send + 'async_trait,
             T: Send + 'async_trait,
             E: Display + Debug + Send + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait;
    fn transaction_with_config<'life0, 'async_trait, F, T, E>(
        &'life0 self,
        callback: F,
        isolation_level: Option<IsolationLevel>,
        access_mode: Option<AccessMode>,
    ) -> Pin<Box<dyn Future<Output = Result<T, TransactionError<E>>> + Send + 'async_trait>>
       where F: for<'c> FnOnce(&'c Self::Transaction) -> Pin<Box<dyn Future<Output = Result<T, E>> + Send + 'c>> + Send + 'async_trait,
             T: Send + 'async_trait,
             E: Display + Debug + Send + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Begin a database transaction.

Implemented by DatabaseConnection and DatabaseTransaction (allowing nested transactions via SAVEPOINTs). Use begin for a manually managed transaction, or transaction for a closure that auto-commits on Ok and rolls back on Err.

Self::Transaction must be a fixed point — its own transaction type is itself — because the ActiveModelEx mutation methods recurse through it (see https://github.com/SeaQL/sea-orm/issues/3147).

Required Associated Types§

Source

type Transaction: ConnectionTrait + TransactionTrait<Transaction = Self::Transaction> + TransactionSession + Send

The concrete type for the transaction

Required Methods§

Source

fn begin<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Self::Transaction, DbErr>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute SQL BEGIN transaction. Returns a Transaction that can be committed or rolled back

Source

fn begin_with_config<'life0, 'async_trait>( &'life0 self, isolation_level: Option<IsolationLevel>, access_mode: Option<AccessMode>, ) -> Pin<Box<dyn Future<Output = Result<Self::Transaction, DbErr>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute SQL BEGIN transaction with isolation level and/or access mode. Returns a Transaction that can be committed or rolled back

Source

fn begin_with_options<'life0, 'async_trait>( &'life0 self, options: TransactionOptions, ) -> Pin<Box<dyn Future<Output = Result<Self::Transaction, DbErr>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute SQL BEGIN transaction with isolation level and/or access mode. Returns a Transaction that can be committed or rolled back

Source

fn transaction<'life0, 'async_trait, F, T, E>( &'life0 self, callback: F, ) -> Pin<Box<dyn Future<Output = Result<T, TransactionError<E>>> + Send + 'async_trait>>
where F: for<'c> FnOnce(&'c Self::Transaction) -> Pin<Box<dyn Future<Output = Result<T, E>> + Send + 'c>> + Send + 'async_trait, T: Send + 'async_trait, E: Display + Debug + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Execute the function inside a transaction. If the function returns an error, the transaction will be rolled back. If it does not return an error, the transaction will be committed.

Source

fn transaction_with_config<'life0, 'async_trait, F, T, E>( &'life0 self, callback: F, isolation_level: Option<IsolationLevel>, access_mode: Option<AccessMode>, ) -> Pin<Box<dyn Future<Output = Result<T, TransactionError<E>>> + Send + 'async_trait>>
where F: for<'c> FnOnce(&'c Self::Transaction) -> Pin<Box<dyn Future<Output = Result<T, E>> + Send + 'c>> + Send + 'async_trait, T: Send + 'async_trait, E: Display + Debug + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Execute the function inside a transaction with isolation level and/or access mode. If the function returns an error, the transaction will be rolled back. If it does not return an error, the transaction will be committed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§