MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / transaction

Method transaction

src/driver/sqlx_mysql.rs:203–227  ·  view source on GitHub ↗
(
        &self,
        callback: F,
        isolation_level: Option<IsolationLevel>,
        access_mode: Option<AccessMode>,
    )

Source from the content-addressed store, hash-verified

201 /// Create a MySQL transaction
202 #[instrument(level = "trace", skip(callback))]
203 pub async fn transaction<F, T, E>(
204 &self,
205 callback: F,
206 isolation_level: Option<IsolationLevel>,
207 access_mode: Option<AccessMode>,
208 ) -> Result<T, TransactionError<E>>
209 where
210 F: for<'b> FnOnce(
211 &'b DatabaseTransaction,
212 ) -> Pin<Box<dyn Future<Output = Result<T, E>> + Send + 'b>>
213 + Send,
214 T: Send,
215 E: std::fmt::Display + std::fmt::Debug + Send,
216 {
217 let conn = self.pool.acquire().await.map_err(sqlx_conn_acquire_err)?;
218 let transaction = DatabaseTransaction::new_mysql(
219 conn,
220 self.metric_callback.clone(),
221 isolation_level,
222 access_mode,
223 )
224 .await
225 .map_err(|e| TransactionError::Connection(e))?;
226 transaction.run(callback).await
227 }
228
229 pub(crate) fn set_metric_callback<F>(&mut self, callback: F)
230 where

Callers 1

Calls 2

ConnectionClass · 0.85
runMethod · 0.45

Tested by 1