postgresql

package
v0.0.0-...-3910e7f Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNothingInserted = errors.New("nothing inserted")
)

Functions

func Create

func Create(ctx context.Context, client Client, statement *sq.InsertBuilder) error

Create - Create item.

func Delete

func Delete(ctx context.Context, client Client, statement sq.DeleteBuilder) error

Delete - Delete item.

func DoWithAttempts

func DoWithAttempts(fn func() error, maxAttempts int, delay time.Duration) error

func ErrCommit

func ErrCommit(err error) error

func ErrCreateQuery

func ErrCreateQuery(err error) error

func ErrCreateTx

func ErrCreateTx(err error) error

func ErrDoQuery

func ErrDoQuery(err error) error

func ErrExec

func ErrExec(err error) error

func ErrFieldNotFound

func ErrFieldNotFound(fieldName string) error

func ErrNoRowForID

func ErrNoRowForID(id string) error

func ErrNoRowForTableUpdated

func ErrNoRowForTableUpdated() error

func ErrNoRowForURL

func ErrNoRowForURL(url string) error

func ErrNoRowForUpdatedAt

func ErrNoRowForUpdatedAt(id string) error

func ErrNoRows

func ErrNoRows() error

func ErrRollback

func ErrRollback(err error) error

func ErrScan

func ErrScan(err error) error

func Get

func Get(ctx context.Context, client Client, statement sq.SelectBuilder) (pgx.Rows, error)

Get - Get item

func List

func List(ctx context.Context, client Client, statement sq.SelectBuilder) (pgx.Rows, error)

List - List items.

func MaxSortOrder

func MaxSortOrder(ctx context.Context, client Client, qb sq.StatementBuilderType, tableName *string) (*uint64, error)

func NewClient

func NewClient(
	ctx context.Context,
	maxAttempts int,
	maxDelay time.Duration,
	config *Config,
	binary bool,
) (pool *pgxpool.Pool, err error)

NewClient creates new postgres client.

func ParsePgError

func ParsePgError(err error) error

func PrettySQL

func PrettySQL(q string) string

func TableIndexCount

func TableIndexCount(ctx context.Context, client Client, statement sq.SelectBuilder) (*uint64, error)

func Update

func Update(ctx context.Context, client Client, statement sq.UpdateBuilder) error

Update - Update item.

func UpdatedAt

func UpdatedAt(ctx context.Context, client Client, statement sq.SelectBuilder) (*time.Time, error)

Types

type Client

type Client interface {
	Close()
	Acquire(ctx context.Context) (*pgxpool.Conn, error)
	AcquireFunc(ctx context.Context, f func(*pgxpool.Conn) error) error
	AcquireAllIdle(ctx context.Context) []*pgxpool.Conn
	Stat() *pgxpool.Stat
	Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
	Begin(ctx context.Context) (pgx.Tx, error)
	BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error)
}

type Config

type Config struct {
	Host     string
	Port     string
	User     string
	Password string
	DB       string
}

func (*Config) ConnStringFromCfg

func (c *Config) ConnStringFromCfg() string

Jump to

Keyboard shortcuts

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