21 lines
695 B
Go
21 lines
695 B
Go
|
|
package postgres
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"github.com/jackc/pgx/v5"
|
||
|
|
"github.com/jackc/pgx/v5/pgconn"
|
||
|
|
)
|
||
|
|
|
||
|
|
// Executor is the shared query interface for both the connection pool and
|
||
|
|
// an active transaction. Repository code accepts Executor so it works
|
||
|
|
// identically inside and outside a [UnitOfWork].
|
||
|
|
type Executor interface {
|
||
|
|
// Exec executes a query that returns no rows.
|
||
|
|
Exec(ctx context.Context, sql string, args ...any) (pgconn.CommandTag, error)
|
||
|
|
// Query executes a query that returns rows.
|
||
|
|
Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
|
||
|
|
// QueryRow executes a query that returns at most one row.
|
||
|
|
QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
|
||
|
|
}
|