Documentation
¶
Index ¶
- Variables
- func ScanAny(v any, dest any) error
- type Action
- type Compiler
- type Condition
- func Eq(field string, value any) Condition
- func Gt(field string, value any) Condition
- func Gte(field string, value any) Condition
- func In(field string, value any) Condition
- func IsNotNull(field string) Condition
- func Like(field string, value any) Condition
- func Lt(field string, value any) Condition
- func Lte(field string, value any) Condition
- func Neq(field string, value any) Condition
- func Or(c Condition) Condition
- type Conn
- type Executor
- type Order
- type Plan
- type Query
- type Rows
- type Scanner
- type TxBoundExecutor
- type TxExecutor
Constants ¶
This section is empty.
Variables ¶
var ErrNoRows = fmt.Err("no", "rows")
ErrNoRows is the agnostic sentinel for "query returned no rows". Conn implementations (postgres, sqlt) must map their driver-specific no-rows error to this value so callers can detect it without importing database/sql. This is the raw contract sentinel; orm.QB.ReadOne translates it to the ergonomic orm.ErrNotFound — db itself never does that translation.
Functions ¶
Types ¶
type Action ¶
type Action int
Action represents the type of database DML operation. Purely DML — no DDL here (see §2).
type Compiler ¶
Compiler converts agnostic Query values into engine-specific Plans. Each backend dialect (postgres, sqlite) implements this to render its own SQL.
type Condition ¶
type Condition struct {
// contains filtered or unexported fields
}
Condition represents a filter for a query. Sealed value type constructed via helper functions.
type Conn ¶
Conn is what a storage backend implements: the union of Executor and Compiler. Every real backend (postgres, sqlt, indexdb) is a single concrete type satisfying both halves — Conn names that pairing so it travels as one value instead of two arguments that could be mismatched (an Executor from one backend paired with a Compiler from another is an illegal state that used to be representable as two constructor args; Conn makes it impossible).
type Executor ¶
type Executor interface {
Exec(query string, args ...any) error
QueryRow(query string, args ...any) Scanner
Query(query string, args ...any) (Rows, error)
Close() error
}
Executor represents the database connection abstraction. It must remain compatible with sql.DB, sql.Tx, mocks, and WASM drivers.
type Order ¶
type Order struct {
// contains filtered or unexported fields
}
Order represents a sort order for a query. Sealed value type — construct with Asc/Desc.
type Plan ¶
Plan describes how a Conn should run the operation: the compiled query and its arguments.
type Query ¶
type Query struct {
Action Action
Table string
Columns []string
Values []any
Conditions []Condition
OrderBy []Order
GroupBy []string
Limit int
Offset int
}
Query represents a database DML query to be compiled and run by a Conn. Compilers read these fields to build a Plan.
type Rows ¶
type Rows interface {
Next() bool
Scan(dest ...any) error
Columns() ([]string, error)
Close() error
Err() error
}
Rows represents an iterator over query results.
type TxBoundExecutor ¶
TxBoundExecutor represents an executor bound to a transaction.
type TxExecutor ¶
type TxExecutor interface {
Executor
BeginTx() (TxBoundExecutor, error)
}
TxExecutor represents an executor that supports transactions. A Conn optionally implements this (type-assert it) to signal transaction support.