Documentation
¶
Overview ¶
Package r3pgx is a raw-SQL r3.CRUD[T, ID] driver backed by jackc/pgx (github.com/jackc/pgx/v5) in database/sql compatibility mode (pgx/v5/stdlib), so it runs through database/sql while keeping pgx's connection and type support.
It builds SQL by reflection and scans into structs tagged `db:"col,pk"`; no ORM, so no preloads and no soft-delete (IncludeTrashed, Restore, HardDelete are unavailable). Table names derive from the struct name (CamelCase -> snake_case, pluralized); nullable columns need pointer fields. The r3 SQL dialect emits `?` placeholders, converted to Postgres `$1, $2, ...` internally. Transactions via r3.Transactor; reach the *sql.DB through Raw().DB for CTEs and the like.
Index ¶
- func NewPgxQuerier[T any, ID comparable](db *sql.DB, opts ...r3.Option) r3.Querier[T, ID]
- type PgxCRUD
- type PgxRawdeprecated
- func (r *PgxRaw[T, ID]) DB() *sql.DB
- func (r *PgxRaw[T, ID]) Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (r *PgxRaw[T, ID]) Query(ctx context.Context, query string, args ...any) ([]T, error)
- func (r *PgxRaw[T, ID]) QueryRow(ctx context.Context, query string, args ...any) (T, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPgxQuerier ¶
NewPgxQuerier builds a read-only repository (r3.Querier enforces it).
Types ¶
type PgxCRUD ¶
type PgxCRUD[T any, ID comparable] struct { *enginesql.BaseCRUD[T, ID] }
PgxCRUD is a pgx repository (via pgx/v5/stdlib); enginesql.BaseCRUD supplies the r3.CRUD impl.
func NewPgxCRUD ¶
NewPgxCRUD builds a repository. Map columns with `db:"column_name"` and mark the PK with `db:"id,pk"` (defaults to "id").
type PgxRaw
deprecated
PgxRaw wraps enginesql.BaseRaw.
Deprecated: use enginesql.BaseRaw directly via PgxCRUD.Raw().
func NewPgxRaw ¶
func NewPgxRaw[T any, ID comparable](db *sql.DB) *PgxRaw[T, ID]
NewPgxRaw creates a new PgxRaw instance.
func (*PgxRaw[T, ID]) Exec ¶
Exec executes a raw SQL query that does not return rows (INSERT, UPDATE, DELETE).