pgxtransactor

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 4 Imported by: 0

README

pgxpool-transactor

License

pgxpool-transactor is a pgxpool wrapper to execute code fragments within postgres transaction.

Easiest way to get the perfect repository.

Installation

go get github.com/golangmonster/pgxpool-transactor/v1

Usage

import pgxtransactor "github.com/golangmonster/pgxpool-transactor"


type repository struct {
	pool *pgxtransactor.Pool
	pgxpool.Transactor
}

func New(pool *pgxpool.Pool) *repository {
	return &repository{
		pool:       pool,
		Transactor: pool,
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

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

func New

func New(pool *pgxpool.Pool) *Pool

func (*Pool) InTx

func (p *Pool) InTx(ctx context.Context, fn func(ctx context.Context) error) error

func (*Pool) InTxWithIsoLevel

func (p *Pool) InTxWithIsoLevel(ctx context.Context, isoLevel pgx.TxIsoLevel, fn func(ctx context.Context) error) error

func (*Pool) Querier

func (p *Pool) Querier(ctx context.Context) Querier

type Querier

type Querier interface {
	Exec(ctx context.Context, sql string, arguments ...any) (commandTag pgconn.CommandTag, err error)
	Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
	CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)
}

type Transactor

type Transactor interface {
	InTx(ctx context.Context, fn func(ctx context.Context) error) error
	InTxWithIsoLevel(ctx context.Context, isoLevel pgx.TxIsoLevel, fn func(ctx context.Context) error) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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