Documentation
¶
Index ¶
- Variables
- type Action
- type Adapter
- 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 Model
- type Order
- 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(factory func() Model, each func(Model)) error
- func (qb *QB) ReadOne() error
- func (qb *QB) Where(conds ...Condition) *QB
- type Query
- type TxAdapter
- type TxBound
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 adapter does not implement TxAdapter.
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 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 Adapter. Adapters read these fields to build native queries.