Documentation
¶
Overview ¶
Package r3pq is a raw-SQL r3.CRUD[T, ID] driver backed by lib/pq (github.com/lib/pq) over database/sql.
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 NewPqQuerier[T any, ID comparable](db *sql.DB, opts ...r3.Option) r3.Querier[T, ID]
- type PqCRUD
- type PqRawdeprecated
- func (r *PqRaw[T, ID]) DB() *sql.DB
- func (r *PqRaw[T, ID]) Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (r *PqRaw[T, ID]) Query(ctx context.Context, query string, args ...any) ([]T, error)
- func (r *PqRaw[T, ID]) QueryRow(ctx context.Context, query string, args ...any) (T, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPqQuerier ¶
NewPqQuerier builds a read-only repository (r3.Querier enforces it).
Types ¶
type PqCRUD ¶
type PqCRUD[T any, ID comparable] struct { *enginesql.BaseCRUD[T, ID] }
PqCRUD is a lib/pq repository; enginesql.BaseCRUD supplies the r3.CRUD impl.
func NewPqCRUD ¶
NewPqCRUD builds a repository. Map columns with `db:"column_name"` and mark the PK with `db:"id,pk"` (defaults to "id").
type PqRaw
deprecated
PqRaw wraps enginesql.BaseRaw.
Deprecated: use enginesql.BaseRaw directly via PqCRUD.Raw().
func NewPqRaw ¶
func NewPqRaw[T any, ID comparable](db *sql.DB) *PqRaw[T, ID]
NewPqRaw creates a new PqRaw instance.