Documentation ¶
Index ¶
- Variables
- func Visit(q *Query, visitor func(pred interface{}))
- type AndNestedWhere
- type AndWhere
- type Columns
- type FetchPlan
- func (e *FetchPlan) CanFetchRelation(rel entity.Relation) bool
- func (e *FetchPlan) EntityName() entity.Name
- func (e *FetchPlan) GetChildPlan(rel entity.Relation) *FetchPlan
- func (e *FetchPlan) HasJoins() bool
- func (e *FetchPlan) NoNestedWhere() bool
- func (e *FetchPlan) PKs() []interface{}
- func (e *FetchPlan) WhereExprCount() int
- type From
- type GroupBy
- type Having
- type Join
- type JoinType
- type Limit
- type NestedWhere
- type Offset
- type OrNestedWhere
- type OrWhere
- type Order
- type Query
- func (q *Query) AndNestedWhere(f func(q *Query)) *Query
- func (q *Query) AndWhere(field, operator string, params ...interface{}) *Query
- func (q *Query) ForEntity(targetEntityMeta *entity.MetaInfo) *Query
- func (q *Query) From(tableName string) *Query
- func (q *Query) GroupBy(expr string) *Query
- func (q *Query) Having(field, operator string, params ...interface{}) *Query
- func (q *Query) Join(joinType JoinType, table string, on string) *Query
- func (q *Query) Limit(l int) *Query
- func (q *Query) Offset(o int) *Query
- func (q *Query) OrNestedWhere(f func(q *Query)) *Query
- func (q *Query) OrWhere(field, operator string, params ...interface{}) *Query
- func (q *Query) OrderBy(stmts ...string) *Query
- func (q *Query) Select(columns ...string) *Query
- func (q *Query) Union(query *Query) *Query
- func (q *Query) Where(field, operator string, params ...interface{}) *Query
- func (q *Query) With(entityName entity.Name) error
- type Union
- type Where
Constants ¶
This section is empty.
Variables ¶
var ( ErrRelatedEntityNotFound = errors.New("related entity not found") ErrRelatedFieldNotFound = errors.New("related field not found") )
var Preprocessor preprocessor
Functions ¶
Types ¶
type AndNestedWhere ¶
type AndNestedWhere struct {
NestedWhere
}
type FetchPlan ¶
type FetchPlan struct {
// contains filtered or unexported fields
}
func (*FetchPlan) EntityName ¶
func (*FetchPlan) NoNestedWhere ¶
func (*FetchPlan) WhereExprCount ¶
type NestedWhere ¶
type NestedWhere struct {
Supply func(query *Query)
}
type OrNestedWhere ¶
type OrNestedWhere struct {
NestedWhere
}
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
func (*Query) AndNestedWhere ¶
AndNestedWhere join nested WHERE expression in select query with AND operator. Example:
q.AndWhere("a", "=", 1).AndNestedWhere(func(q *Query){ q.OrWhere("b", "=", 2).OrWhere("c", "=", 3) }) - generate sql: WHERE a=? AND (b=? OR c=?)
func (*Query) AndWhere ¶
AndWhere join WHERE expression in select query with AND operator. Example: q.AndWhere("a", "=", 1).AndWhere("b", "=",2) - generate sql: WHERE a=? AND b=?
q.AndWhere("a", "IS NOT NULL") - generate sql: WHERE a IS NOT NULL
func (*Query) Join ¶
Join - add JOIN clause to query. Example: q.Join(JoinRight, "profile", "user.id=profile.user_id")
func (*Query) OrNestedWhere ¶
OrNestedWhere join nested WHERE expression in select query with OR operator. Example:
q.OrWhere("a", "=", 1).OrNestedWhere(func(q *Query){ q.AndWhere("b", "=", 2).AndWhere("c", "=", 3) }) - generate sql: WHERE a=? OR (b=? AND c=?)
func (*Query) OrWhere ¶
OrWhere join WHERE expression in select query with OR operator. Example: q.AndWhere("a", "=", 1).OrWhere("b", "=",2) - generate sql: WHERE a=? OR b=?
q.OrWhere("a", "IS NOT NULL") - generate sql: WHERE a IS NOT NULL