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

Method transaction

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

Source from the content-addressed store, hash-verified

232 /// Create a PostgreSQL transaction
233 #[instrument(level = "trace", skip(callback))]
234 pub async fn transaction<F, T, E>(
235 &self,
236 callback: F,
237 isolation_level: Option<IsolationLevel>,
238 access_mode: Option<AccessMode>,
239 ) -> Result<T, TransactionError<E>>
240 where
241 F: for<'b> FnOnce(
242 &'b DatabaseTransaction,
243 ) -> Pin<Box<dyn Future<Output = Result<T, E>> + Send + 'b>>
244 + Send,
245 T: Send,
246 E: std::fmt::Display + std::fmt::Debug + Send,
247 {
248 let conn = self.pool.acquire().await.map_err(sqlx_conn_acquire_err)?;
249 let transaction = DatabaseTransaction::new_postgres(
250 conn,
251 self.metric_callback.clone(),
252 isolation_level,
253 access_mode,
254 )
255 .await
256 .map_err(|e| TransactionError::Connection(e))?;
257 transaction.run(callback).await
258 }
259
260 pub(crate) fn set_metric_callback<F>(&mut self, callback: F)
261 where

Callers

nothing calls this directly

Calls 2

ConnectionClass · 0.85
runMethod · 0.45

Tested by

no test coverage detected