sqlx_utils/traits/repository/transactions/
insert_tx.rs

1use crate::prelude::*;
2use std::future::Future;
3
4pub trait InsertableRepositoryTransaction<M: Model>:
5    InsertableRepository<M> + TransactionRepository<M>
6{
7    fn insert_in_transaction<'a>(
8        &'a self,
9        model: M,
10    ) -> impl Future<Output = Result<M, Error>> + Send + 'a
11    where
12        M: 'a,
13    {
14        self.with_transaction(move |mut tx| async move {
15            let res = self.insert_with_executor(&mut *tx, model).await;
16
17            (res, tx)
18        })
19    }
20}