Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TextOrNull ¶ added in v1.10.0
TextOrNull returns a NULL pgtype.Text for an empty string, or a valid one otherwise.
func TimestampOrNull ¶ added in v1.10.0
func TimestampOrNull(t time.Time) pgtype.Timestamptz
TimestampOrNull returns a NULL pgtype.Timestamptz for the zero time, or a valid one otherwise.
func WithTransaction ¶ added in v1.10.0
WithTransaction runs fn within a database transaction, committing if fn returns nil and rolling back otherwise.
Types ¶
type Database ¶
type Database interface {
Ping(context.Context, time.Duration) error
Query(ctx context.Context, query string, args ...any) (pgx.Rows, error)
QueryRow(ctx context.Context, query string, args ...any) pgx.Row
Exec(ctx context.Context, query string, args ...any) (pgconn.CommandTag, error)
BeginTx(ctx context.Context) (Transaction, error)
Close() error
}
func MustConnect ¶
type Transaction ¶
type Transaction interface {
Query(ctx context.Context, query string, args ...any) (pgx.Rows, error)
QueryRow(ctx context.Context, query string, args ...any) pgx.Row
Exec(ctx context.Context, query string, args ...any) (pgconn.CommandTag, error)
Commit(ctx context.Context) error
Rollback(ctx context.Context) error
}
Click to show internal directories.
Click to hide internal directories.