pub async fn with_transaction<D, T, F>(ds: &D, work: F) -> Result<T, DataError>Expand description
Run work inside one transaction: commit on Ok, roll back on Err.
ⓘ
let order = with_transaction(ds, |tx| Box::pin(async move {
let order = repo.insert_order(tx, &dto).await?;
tx.enqueue(OutboxEntry { topic: "order.created".into() /* ... */ }).await?;
Ok(order)
})).await?;