transaction

package
v0.0.0-...-32f39c9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Transaction

type Transaction interface {
	Commit(ctx context.Context) error
	Rollback(ctx context.Context) error
	QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
	Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
	Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error)
}

Transaction defines the interface for handling transactions.

type TxManager

type TxManager struct {
	// contains filtered or unexported fields
}

TxManager provides a concrete implementation of the Transaction interface.

func NewTxManager

func NewTxManager(tx pgx.Tx) *TxManager

NewTxManager creates a new transaction manager from an existing pgx.Tx.

func (*TxManager) Commit

func (m *TxManager) Commit(ctx context.Context) error

Commit commits the current transaction.

func (*TxManager) Exec

func (m *TxManager) Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error)

Exec executes a query that doesn't return rows and returns a CommandTag.

func (*TxManager) Query

func (m *TxManager) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)

Query executes a query that returns multiple rows.

func (*TxManager) QueryRow

func (m *TxManager) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row

QueryRow executes a query that is expected to return at most one row.

func (*TxManager) Rollback

func (m *TxManager) Rollback(ctx context.Context) error

Rollback rolls back the current transaction.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL