Documentation
¶
Index ¶
- Variables
- func GenerateCodeForStruct(structName string, goFile string)
- func RunOrmcCLI()
- type Action
- type Clause
- 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 FieldInfo
- type Model
- type Order
- type OrderClause
- 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) Or() *QB
- func (qb *QB) OrderBy(column string) *OrderClause
- func (qb *QB) ReadAll(new func() Model, onRow func(Model)) error
- func (qb *QB) ReadOne() error
- func (qb *QB) Where(column string) *Clause
- type Query
- type Rows
- type Scanner
- type StructInfo
- 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 ¶
func GenerateCodeForStruct ¶ added in v0.0.8
GenerateCodeForStruct reads the Go File and generates the ORM implementations for a given struct name. This func is made public to allow easy programmatic testing.
Types ¶
type Clause ¶ added in v0.0.8
type Clause struct {
// contains filtered or unexported fields
}
Clause represents an intermediate state for building a query condition.
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 OrderClause ¶ added in v0.0.8
type OrderClause struct {
// contains filtered or unexported fields
}
OrderClause represents an intermediate state for building an order by clause.
func (*OrderClause) Asc ¶ added in v0.0.8
func (o *OrderClause) Asc() *QB
Asc sets the order direction to ascending.
func (*OrderClause) Desc ¶ added in v0.0.8
func (o *OrderClause) Desc() *QB
Desc sets the order direction to descending.
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.
func (*QB) OrderBy ¶
func (qb *QB) OrderBy(column string) *OrderClause
OrderBy starts a new order clause for the given column.
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 StructInfo ¶ added in v0.0.8
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.