Documentation ¶
Overview ¶
Example ¶
var pool *pgxpool.Pool db, err := pgxutil.New(pool) if err != nil { panic(err) } ctx := context.Background() // to make transaction with a given isolation level level := pgx.Serializable errTx := db.InTx(ctx, level, func(tx pgx.Tx) error { // TODO: good query with tx return nil }) if errTx != nil { panic(errTx) } // to make read-only transaction with a read committed isolation level errRead := db.InReadOnlyTx(ctx, func(tx pgx.Tx) error { // TODO: good read-only query with tx return nil }) if errRead != nil { panic(errRead) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) InReadOnlyTx ¶
InReadOnlyTx runs the given function within a read-only transaction with read commited isolation level.
Click to show internal directories.
Click to hide internal directories.