Documentation
¶
Overview ¶
Package mqsqlite is the database/sql adapter for metaquery builders targeting SQLite. It executes a *metaquery.Builder and returns an untyped Result or a typed TypedResult[T] using only the standard library.
The adapter is driver-agnostic: it works with any database/sql driver registered for SQLite (e.g. modernc.org/sqlite, mattn/go-sqlite3, libsql). The wrapped query's Dialect must be metaquery.DialectSQLite so the Builder emits SQLite-compatible ?N placeholders.
Index ¶
- func Run(ctx context.Context, q Queryer, b *metaquery.Builder) (*metaquery.Result, error)
- func Scan[T any](ctx context.Context, q Queryer, b *metaquery.Builder) (*metaquery.TypedResult[T], error)
- func ScanOne[T any](ctx context.Context, q Queryer, b *metaquery.Builder) (T, metaquery.Meta, error)
- type Queryer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
Run executes b and returns every row as a positional []any in the same order as Meta.Columns. If b.WantsTotal(), a follow-up COUNT(*) is issued and Meta.Pagination.Total is populated.
func Scan ¶
func Scan[T any](ctx context.Context, q Queryer, b *metaquery.Builder) (*metaquery.TypedResult[T], error)
Scan executes b, scans rows into []T using `db` struct tags (snake_case fallback), and returns a TypedResult with the same Meta envelope as Run. T is validated against b.OutputColumns() before querying.
Types ¶
type Queryer ¶
type Queryer interface {
QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
}
Queryer is the minimal database/sql surface the adapter needs. Implemented by *sql.DB, *sql.Tx, and *sql.Conn.