pub fn transaction<F, T>(operations: F) -> Result<T, Error>
Expand description
Transaction functions for PostgreSQL
These functions provide a way to execute queries within a transaction. The transaction is automatically committed when the function returns successfully, or rolled back if an error occurs.
Example:
use sal_postgresclient::{transaction, QueryParams};
let result = transaction(|client| {
// Execute queries within the transaction
client.execute("INSERT INTO users (name) VALUES ($1)", &[&"John"])?;
client.execute("UPDATE users SET active = true WHERE name = $1", &[&"John"])?;
// Return a result from the transaction
Ok(())
});