go-transaction-manager
29 строк · 1.2 Кб
1// Package pgxv4 is an implementation of trm.Transaction interface by Transaction for pgx.Tx.
2package pgxv43
4import (5"context"6
7"github.com/jackc/pgconn"8"github.com/jackc/pgx/v4"9)
10
11// Tr is an interface to work with pgx.Conn, pgxpool.Conn or pgxpool.Pool
12// StmtContext and Stmt are not implemented!
13type Tr interface {14Begin(ctx context.Context) (pgx.Tx, error)15BeginFunc(ctx context.Context, f func(pgx.Tx) error) (err error)16
17CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)18SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults19
20Exec(ctx context.Context, sql string, arguments ...interface{}) (commandTag pgconn.CommandTag, err error)21Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)22QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row23QueryFunc(ctx context.Context, sql string, args []interface{}, scans []interface{}, f func(pgx.QueryFuncRow) error) (pgconn.CommandTag, error)24}
25
26// Transactional is an interface to work with pgx.Conn, pgxpool.Conn or pgxpool.Pool.
27type Transactional interface {28BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error)29}
30