Documentation ¶
Index ¶
- func Build(ctx context.Context, f func(builder *Builder)) context.Context
- func WithBuilder(ctx context.Context, b *Builder) context.Context
- type Builder
- func (b *Builder) Build(query string, args ...interface{}) (string, []interface{}, error)
- func (b *Builder) Group(cols string) *Builder
- func (b *Builder) In(column string, args ...interface{}) *Builder
- func (b *Builder) Limit(x int) *Builder
- func (b *Builder) Offset(x int) *Builder
- func (b *Builder) Order(cols string) *Builder
- func (b *Builder) Where(query string, args ...interface{}) *Builder
- func (b *Builder) WhereCompare(column string, operator string, args ...interface{}) *Builder
- func (b *Builder) WhereCondition(query string, condition FilterCondition, args ...interface{}) *Builder
- type DBTX
- type FilterCondition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Builder ¶
type Builder struct { RowCount int // contains filtered or unexported fields }
Builder is a SQL query builder.
It supports dynamic WHERE conditions, ORDER BY, LIMIT, and OFFSET. For dynamic WHERE and ORDER BY clauses, only the parent table rows can be used. It uses vitess sqlparser to parse the query and rewrite it.
func (*Builder) Where ¶
Where set conditions of where in SELECT Where("user = ?","tom") Where("a = ? OR b = ?",1,2)
Requires 3 arguments, first is key, second is operator and third is a argument to be replaced with a placeholder.
Requires spaces between conditions to work.
func (*Builder) WhereCompare ¶
Perform tuple based comparision like ("a", "b") > (@value_of_a, @value_of_b)
func (*Builder) WhereCondition ¶
func (b *Builder) WhereCondition(query string, condition FilterCondition, args ...interface{}) *Builder
WhereCondition set conditions of where in SELECT with specified AND or OR
type DBTX ¶
type FilterCondition ¶
type FilterCondition int
const ( FilterConditionAnd FilterCondition = iota FilterConditionOr )
Click to show internal directories.
Click to hide internal directories.