storage

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrGeneral = errors.New("general storage error")
View Source
var ErrModelNotFound = errors.New("storage model not found")

Functions

func NewErrGeneral

func NewErrGeneral(op string, err error) error

func NewErrModelNotFound

func NewErrModelNotFound(op, model string) error

func NewRaw

func NewRaw(
	ctx context.Context,
	user, password, host, name string,
	port uint32,
	maxConnections, minConnections byte,
	debug bool,
) (*sql.DB, error)

Types

type PgStorage

type PgStorage interface {
	Begin(ctx context.Context, op string) (PgTx, error)
	BeginTx(ctx context.Context, opts pgx.TxOptions, op string) (PgTx, error)
	Queryable
}

type PgTag

type PgTag interface {
	RowsAffected() int64
	String() string
	NothingUpdated() bool
}

type PgTx

type PgTx interface {
	Queryable
	Commit(ctx context.Context, op string) error
	Rollback(ctx context.Context, op string)
	SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults
}

type Postgres

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

func New

func New(
	ctx context.Context,
	user, password, host, name string,
	port uint32,
	maxConnections, minConnections byte,
	debug bool,
) (*Postgres, error)

func (*Postgres) Begin

func (s *Postgres) Begin(ctx context.Context, op string) (PgTx, error)

func (*Postgres) BeginTx

func (s *Postgres) BeginTx(ctx context.Context, opts pgx.TxOptions, op string) (PgTx, error)

func (*Postgres) Check added in v1.12.0

func (s *Postgres) Check(ctx context.Context) error

func (*Postgres) Close

func (s *Postgres) Close(_ context.Context) error

func (*Postgres) CopyFrom

func (s *Postgres) CopyFrom(
	ctx context.Context,
	tableName pgx.Identifier,
	columnNames []string,
	rowSrc pgx.CopyFromSource,
) (int64, error)

func (*Postgres) Exec

func (s *Postgres) Exec(ctx context.Context, sql string, arguments ...any) (PgTag, error)

func (*Postgres) Query

func (s *Postgres) Query(ctx context.Context, sql string, args ...any) (rows pgx.Rows)

func (*Postgres) QueryRow

func (s *Postgres) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row

type Queryable

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

type Tag

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

func (Tag) NothingUpdated

func (t Tag) NothingUpdated() bool

func (Tag) RowsAffected

func (t Tag) RowsAffected() int64

func (Tag) String

func (t Tag) String() string

type Tx

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

func (Tx) Commit

func (t Tx) Commit(ctx context.Context, op string) error

func (Tx) CopyFrom

func (t Tx) CopyFrom(
	ctx context.Context,
	tableName pgx.Identifier,
	columnNames []string,
	rowSrc pgx.CopyFromSource,
) (int64, error)

func (Tx) Exec

func (t Tx) Exec(ctx context.Context, sql string, arguments ...any) (PgTag, error)

func (Tx) Query

func (t Tx) Query(ctx context.Context, sql string, args ...any) (rows pgx.Rows)

func (Tx) QueryRow

func (t Tx) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row

func (Tx) Rollback

func (t Tx) Rollback(ctx context.Context, op string)

func (Tx) SendBatch

func (t Tx) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults

Jump to

Keyboard shortcuts

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