Documentation
¶
Index ¶
- Variables
- 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 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 DB
- type Executor
- type Model
- type Order
- type Plan
- type QB
- func (qb *QB) GroupBy(columns ...string) *QB
- func (qb *QB) Limit(limit int) *QB
- func (qb *QB) Offset(offset int) *QB
- func (qb *QB) OrderBy(column, dir string) *QB
- func (qb *QB) ReadAll(new func() Model, onRow func(Model)) error
- func (qb *QB) ReadOne() error
- func (qb *QB) Where(conds ...Condition) *QB
- type Query
- type Rows
- type Scanner
- type TxBoundExecutor
- type TxExecutor
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyTable = fmt.Err("name", "table", "empty")
ErrEmptyTable is returned when TableName() returns an empty string.
var ErrNoTxSupport = fmt.Err("transaction", "not", "supported")
ErrNoTxSupport is returned by DB.Tx() when the executor does not implement TxExecutor.
var ErrNotFound = fmt.Err("record", "not", "found")
ErrNotFound is returned when ReadOne() finds no matching row.
var ErrValidation = fmt.Err("error", "validation")
ErrValidation is returned when validate() finds a mismatch.
Functions ¶
This section is empty.
Types ¶
type Condition ¶
type Condition struct {
// contains filtered or unexported fields
}
Condition represents a filter for a query. It is a sealed value type constructed via helper functions.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB represents a database connection. Consumers instantiate it via New().
type Executor ¶ added in v0.0.7
type Executor interface {
Exec(query string, args ...any) error
QueryRow(query string, args ...any) Scanner
Query(query string, args ...any) (Rows, 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. It is a sealed value type constructed via QB.OrderBy().
type QB ¶
type QB struct {
// contains filtered or unexported fields
}
QB represents a query builder. Consumers hold a *QB reference in variables for incremental building.
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 query to be executed by an Executor. Planners read these fields to build Plans.
type TxBoundExecutor ¶ added in v0.0.7
TxBoundExecutor represents an executor bound to a transaction.
type TxExecutor ¶ added in v0.0.7
type TxExecutor interface {
Executor
BeginTx() (TxBoundExecutor, error)
}
TxExecutor represents an executor that supports transactions.