Skip to main content

start_transaction

Macro start_transaction 

Source
macro_rules! start_transaction {
    () => { ... };
}
Expand description

Macro to start a new database transaction.

This macro begins a transaction using the global database pool by calling begin() on it. In case of an error starting the transaction, the error is logged and returned.

ยงExample

use zirv_db_sqlx::{start_transaction, commit_transaction};
 
async fn perform_db_operations() -> Result<(), sqlx::Error> {
    let mut tx = start_transaction!();
    // Execute operations within the transaction...
    commit_transaction!(tx);
    Ok(())
}