Std.Db.withTransaction
1 declaration
fn
withTransaction: Std.Db.Session.Connection -> fn(Std.Db.Session.Connection) -> (Result[T, Std.Db.Session.DbError], Std.Db.Session.Connection) -> (Result[T, Std.Db.Session.DbError], Std.Db.Session.Connection)This is a callable function.
What it does
Run an action inside a transaction, and undo it if the action failed.
There is no rollback a caller can forget. A transaction left open holds
every row it touched against every other connection until something closes
it, and a caller that returned early on a failure — which is exactly when a
rollback matters most — is the commonest way one is left open.
A commit that itself fails is answered as a failure rather than swallowed:
a caller told its work was kept, when the server refused to keep it, would
carry on from a state that does not exist.
Read the signature
- The text after the name is the type checked by Pudu.
- Read arrows from left to right: inputs come first, and the final type is returned.
- Names inside [ ] are type arguments, such as the item type held by a collection.
- Result makes success and recoverable failure part of the function's type.
