postgres

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection interface {
	Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
}

Connection is the pgx behavior required to execute generated queries.

type Preparer

type Preparer interface {
	Prepare(ctx context.Context, name, sql string) (*pgconn.StatementDescription, error)
}

Preparer is the pgx behavior required by generated PrepareStatements.

type Query

type Query[T any] struct {
	SQL      string
	StmtName string
	Args     []any
	Error    error
}

Query is an executable generated PostgreSQL query returning T.

func Retype

func Retype[To any, From any](q *Query[From]) *Query[To]

Retype returns a Query with a result type of a compatible shape.

func (*Query[T]) Execute

func (q *Query[T]) Execute(ctx context.Context, c Connection) (int64, error)

Execute runs q and returns the affected row count.

func (*Query[T]) Get

func (q *Query[T]) Get(ctx context.Context, c Connection) ([]T, error)

Get executes q and maps every returned row.

func (*Query[T]) GetOne

func (q *Query[T]) GetOne(ctx context.Context, c Connection) (*T, error)

GetOne executes the query and enforces only a single result is returned.

type Transaction

type Transaction interface {
	Connection
	Commit(ctx context.Context) error
	Rollback(ctx context.Context) error
}

Transaction is a transactional Connection.

Jump to

Keyboard shortcuts

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