Documentation
¶
Index ¶
- func CtxWithTx(ctx context.Context, db *sql.DB, opts ...TxOptions) (context.Context, error)
- func FinishTxForCtx(ctx context.Context, err error) error
- func MigrateAndConnectToDB(postgresURI string, as *bindata.AssetSource) (*sql.DB, error)
- func TxReadonly() func(o *sql.TxOptions) *sql.TxOptions
- func TxWithIsolation(level sql.IsolationLevel) func(o *sql.TxOptions) *sql.TxOptions
- func WithCtxTx(ctx context.Context, withTx func(*sql.Tx) error, noTx func() error) error
- func WithTx(ctx context.Context, db *sql.DB, f func(*sql.Tx) error, opts ...TxOptions) (err error)
- type TxOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CtxWithTx ¶
CtxWithTx attach a database transaction to the context. It returns the context unchanged if there's error starting the transaction.
func FinishTxForCtx ¶
FinishTxForCtx commits or rolls back the transaction attatched to the context depending on the error passed in and returns the result. It errors if the context doesn't have a transaction attached.
func MigrateAndConnectToDB ¶
MigrateAndConnectToDB run db migrations and return a ready to use connection to the Postgres database.
func TxReadonly ¶
TxReadonly signals the DB driver that the transaction is read-only.
func TxWithIsolation ¶
TxWithIsolation tells the DB driver the isolation level of the transaction.
Types ¶
Click to show internal directories.
Click to hide internal directories.