2
0

Replace Begin and BeginTx methods with functions

This commit is contained in:
Jack Christensen
2022-07-09 17:25:55 -05:00
parent 62f0347586
commit 31ec18cc65
8 changed files with 82 additions and 117 deletions
+2 -2
View File
@@ -247,10 +247,10 @@ These are internally implemented with savepoints.
Use BeginTx to control the transaction mode.
BeginFunc and BeginTxFunc are variants that begin a transaction, execute a function, and commit or rollback the
BeginFunc and BeginTxFunc are functions that begin a transaction, execute a function, and commit or rollback the
transaction depending on the return value of the function. These can be simpler and less error prone to use.
err = conn.BeginFunc(context.Background(), func(tx pgx.Tx) error {
err = pgx.BeginFunc(context.Background(), conn, func(tx pgx.Tx) error {
_, err := tx.Exec(context.Background(), "insert into foo(id) values (1)")
return err
})