pub async fn in_write_tx<F, T, E>(pool: &PgPool, f: F) -> Result<T, E>Expand description
Run f inside one transaction: committed when f returns Ok, rolled back when it returns
Err or is dropped.
Every repository write and scoped statement f runs, in this crate or in a hand-written
service that uses its helpers, rides the transaction (see the module docs). Opened
inside another write transaction for the same pool it is a savepoint of it.
§Errors
f’s own error; or a database error from beginning, binding the scope or committing, converted
through E: From<sqlx::Error>. A failed commit (a deferred constraint, a serialization
failure) is returned as an error and nothing of the transaction survives.