r3pq

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 4 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPqQuerier

func NewPqQuerier[T any, ID comparable](db *sql.DB, opts ...r3.Option) r3.Querier[T, ID]

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

func NewPqCRUD[T any, ID comparable](db *sql.DB, opts ...r3.Option) *PqCRUD[T, ID]

NewPqCRUD builds a repository. Map columns with `db:"column_name"` and mark the PK with `db:"id,pk"` (defaults to "id").

func (*PqCRUD[T, ID]) DB

func (r *PqCRUD[T, ID]) DB() *sql.DB

DB returns the underlying *sql.DB for advanced usage.

func (*PqCRUD[T, ID]) Raw

func (r *PqCRUD[T, ID]) Raw() *enginesql.BaseRaw[T, ID]

Raw returns the BaseRaw escape hatch for custom queries.

type PqRaw deprecated

type PqRaw[T any, ID any] struct {
	*enginesql.BaseRaw[T, ID]
}

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.

func (*PqRaw[T, ID]) DB

func (r *PqRaw[T, ID]) DB() *sql.DB

DB returns the underlying *sql.DB for fully custom usage.

func (*PqRaw[T, ID]) Exec

func (r *PqRaw[T, ID]) Exec(ctx context.Context, query string, args ...any) (sql.Result, error)

Exec executes a raw SQL query that does not return rows.

func (*PqRaw[T, ID]) Query

func (r *PqRaw[T, ID]) Query(ctx context.Context, query string, args ...any) ([]T, error)

Query executes a raw SQL query and scans results into a slice of T.

func (*PqRaw[T, ID]) QueryRow

func (r *PqRaw[T, ID]) QueryRow(ctx context.Context, query string, args ...any) (T, error)

QueryRow executes a raw SQL query expected to return a single row and scans it into T.

Jump to

Keyboard shortcuts

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