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

Method run

src/database/transaction.rs:96–114  ·  view source on GitHub ↗
(self, callback: F)

Source from the content-addressed store, hash-verified

94 /// encountering an error if it fails
95 #[instrument(level = "trace", skip(callback))]
96 pub(crate) async fn run<F, T, E>(self, callback: F) -> Result<T, TransactionError<E>>
97 where
98 F: for<'b> FnOnce(
99 &'b DatabaseTransaction,
100 ) -> Pin<Box<dyn Future<Output = Result<T, E>> + Send + 'b>>
101 + Send,
102 T: Send,
103 E: std::fmt::Display + std::fmt::Debug + Send,
104 {
105 let res = callback(&self).await.map_err(TransactionError::Transaction);
106 if res.is_ok() {
107 self.commit().await.map_err(TransactionError::Connection)?;
108 } else {
109 self.rollback()
110 .await
111 .map_err(TransactionError::Connection)?;
112 }
113 res
114 }
115
116 /// Commit a transaction atomically
117 #[instrument(level = "trace")]

Callers 8

transactionMethod · 0.45
transactionMethod · 0.45
transactionMethod · 0.45
transactionMethod · 0.45
transactionMethod · 0.45
mainFunction · 0.45

Calls 2

commitMethod · 0.45
rollbackMethod · 0.45

Tested by

no test coverage detected