transaction

Macro transaction 

Source
macro_rules! transaction {
    (&$pool:expr, |$tx:ident| async move $body:block) => { ... };
    ($pool:expr, |$tx:ident| async move $body:block) => { ... };
}
Expand description

宏:简化事务闭包的写法,自动处理 Box::pin

使用示例:

// 使用引用
sqlxplus::transaction!(&pool, |tx| async move {
    // 事务代码
    Ok(42)
}).await?;

// 或直接使用值(会自动借用)
sqlxplus::transaction!(pool, |tx| async move {
    // 事务代码
    Ok(42)
}).await?;