Documentation
¶
Overview ¶
Package r3sqlite3 is a raw-SQL r3.CRUD[T, ID] driver backed by mattn/go-sqlite3 (github.com/mattn/go-sqlite3, CGo) 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. Transactions via r3.Transactor; reach the *sql.DB through Raw().DB for CTEs and the like.
SQLite-specific notes:
- No ILIKE (use LIKE; SQLite LIKE is case-insensitive for ASCII by default).
- RETURNING requires SQLite 3.35+ (which go-sqlite3 provides).
Index ¶
- func NewSqlite3Querier[T any, ID comparable](db *sql.DB, opts ...r3.Option) r3.Querier[T, ID]
- type Sqlite3CRUD
- type Sqlite3Rawdeprecated
- func (r *Sqlite3Raw[T, ID]) DB() *sql.DB
- func (r *Sqlite3Raw[T, ID]) Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (r *Sqlite3Raw[T, ID]) Query(ctx context.Context, query string, args ...any) ([]T, error)
- func (r *Sqlite3Raw[T, ID]) QueryRow(ctx context.Context, query string, args ...any) (T, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSqlite3Querier ¶
NewSqlite3Querier builds a read-only repository (r3.Querier enforces it).
Types ¶
type Sqlite3CRUD ¶
type Sqlite3CRUD[T any, ID comparable] struct { *enginesql.BaseCRUD[T, ID] }
Sqlite3CRUD is a mattn/go-sqlite3 repository; enginesql.BaseCRUD supplies the r3.CRUD impl.
func NewSqlite3CRUD ¶
func NewSqlite3CRUD[T any, ID comparable](db *sql.DB, opts ...r3.Option) *Sqlite3CRUD[T, ID]
NewSqlite3CRUD builds a repository. Map columns with `db:"column_name"` and mark the PK with `db:"id,pk"` (defaults to "id").
func (*Sqlite3CRUD[T, ID]) DB ¶
func (r *Sqlite3CRUD[T, ID]) DB() *sql.DB
DB returns the underlying *sql.DB for advanced usage.
func (*Sqlite3CRUD[T, ID]) Raw ¶
func (r *Sqlite3CRUD[T, ID]) Raw() *enginesql.BaseRaw[T, ID]
Raw returns the BaseRaw escape hatch for custom queries.
type Sqlite3Raw
deprecated
Sqlite3Raw wraps enginesql.BaseRaw.
Deprecated: use enginesql.BaseRaw directly via Sqlite3CRUD.Raw().
func NewSqlite3Raw ¶
func NewSqlite3Raw[T any, ID comparable](db *sql.DB) *Sqlite3Raw[T, ID]
NewSqlite3Raw creates a new Sqlite3Raw instance.
func (*Sqlite3Raw[T, ID]) DB ¶
func (r *Sqlite3Raw[T, ID]) DB() *sql.DB
DB returns the underlying *sql.DB for fully custom usage.
func (*Sqlite3Raw[T, ID]) Exec ¶
func (r *Sqlite3Raw[T, ID]) Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
Exec executes a raw SQL query that does not return rows.