Documentation ¶
Index ¶
- Constants
- Variables
- func HolderRepeat(length int) string
- func Star() star
- type Assignment
- type Assignments
- type CanExpr
- type Column
- func (c *Column) Add() *Expression
- func (c *Column) Between(leftValue interface{}, rightValue interface{}) *Condition
- func (c *Column) By(v interface{}) *Assignment
- func (c Column) Def() *Expression
- func (c *Column) Desc(d int) *Expression
- func (c *Column) Drop() *Expression
- func (c Column) Enum(enumType string, enums map[int][]string) *Column
- func (c *Column) Eq(value interface{}) *Condition
- func (c *Column) Expr() *Expression
- func (c Column) Field(fieldName string) *Column
- func (c *Column) Gt(v interface{}) *Condition
- func (c *Column) Gte(v interface{}) *Condition
- func (c *Column) In(args ...interface{}) *Condition
- func (c *Column) Incr(d int) *Expression
- func (c *Column) IsNotNull() *Condition
- func (c *Column) IsNull() *Condition
- func (c *Column) IsValidDef() bool
- func (c *Column) LeftLike(v string) *Condition
- func (c *Column) Like(v string) *Condition
- func (c *Column) Lt(v interface{}) *Condition
- func (c *Column) Lte(v interface{}) *Condition
- func (c *Column) Modify() *Expression
- func (c *Column) Neq(v interface{}) *Condition
- func (c *Column) NotBetween(leftValue interface{}, rightValue interface{}) *Condition
- func (c *Column) NotIn(args ...interface{}) *Condition
- func (c *Column) NotLike(v string) *Condition
- func (c *Column) RightLike(v string) *Condition
- func (c *Column) String() string
- func (c Column) Type(tpe string) *Column
- type Columns
- func (cols *Columns) Add(columns ...*Column)
- func (cols *Columns) AutoIncrement() (col *Column)
- func (cols *Columns) Clone() *Columns
- func (cols *Columns) Col(columnName string) (col *Column)
- func (cols *Columns) Cols(colNames ...string) (columns *Columns)
- func (cols Columns) Diff(targetCols Columns) columnsDiffResult
- func (cols Columns) Expr() (e *Expression)
- func (cols *Columns) F(fileName string) (col *Column)
- func (cols *Columns) FieldNames() []string
- func (cols *Columns) Fields(fieldNames ...string) (columns *Columns)
- func (cols *Columns) IsEmpty() bool
- func (cols *Columns) Len() int
- func (cols *Columns) List() (l []*Column)
- func (cols *Columns) Range(cb func(col *Column, idx int))
- func (cols *Columns) Remove(name string)
- func (cols Columns) Wrap() (e *Expression)
- type CondRule
- type CondRules
- type Condition
- type Database
- type Expression
- type FieldValues
- type Function
- func Avg(canExpr CanExpr) *Function
- func Count(canExpr CanExpr) *Function
- func Distinct(canExpr CanExpr) *Function
- func First(canExpr CanExpr) *Function
- func Func(name string, canExpr CanExpr) *Function
- func Last(canExpr CanExpr) *Function
- func Max(canExpr CanExpr) *Function
- func Min(canExpr CanExpr) *Function
- func Sum(canExpr CanExpr) *Function
- type Key
- type Keys
- func (keys *Keys) Add(nextKeys ...*Key)
- func (keys *Keys) Clone() *Keys
- func (keys Keys) Diff(targetKeys Keys) keysDiffResult
- func (keys *Keys) IsEmpty() bool
- func (keys *Keys) Key(keyName string) (key *Key, exists bool)
- func (keys *Keys) Len() int
- func (keys *Keys) Range(cb func(key *Key, idx int))
- func (keys *Keys) Remove(name string)
- type OrderType
- type Statement
- type Stmt
- type StmtDelete
- func (s StmtDelete) AscendBy(col *Column) *StmtDelete
- func (s StmtDelete) Comment(comment string) *StmtDelete
- func (s StmtDelete) DescendBy(col *Column) *StmtDelete
- func (s *StmtDelete) Expr() *Expression
- func (s StmtDelete) Limit(size int32) *StmtDelete
- func (s StmtDelete) Modifier(modifiers ...string) *StmtDelete
- func (s StmtDelete) OrderBy(col *Column, orderType OrderType) *StmtDelete
- func (s *StmtDelete) Type() StmtType
- func (s StmtDelete) Where(cond *Condition) *StmtDelete
- type StmtInsert
- func (s StmtInsert) Columns(cols Columns) *StmtInsert
- func (s StmtInsert) Comment(comment string) *StmtInsert
- func (s *StmtInsert) Expr() *Expression
- func (s StmtInsert) Modifier(modifiers ...string) *StmtInsert
- func (s StmtInsert) OnDuplicateKeyUpdate(assigns ...*Assignment) *StmtInsert
- func (s *StmtInsert) Type() StmtType
- func (s StmtInsert) Values(values ...interface{}) *StmtInsert
- type StmtSelect
- func (s StmtSelect) Comment(comment string) *StmtSelect
- func (s *StmtSelect) Expr() *Expression
- func (s StmtSelect) For(expr CanExpr) *StmtSelect
- func (s StmtSelect) ForUpdate() *StmtSelect
- func (s StmtSelect) GroupAscBy(canExpr CanExpr) *StmtSelect
- func (s StmtSelect) GroupBy(canExpr CanExpr) *StmtSelect
- func (s StmtSelect) GroupDescBy(canExpr CanExpr) *StmtSelect
- func (s StmtSelect) Having(cond *Condition) *StmtSelect
- func (s StmtSelect) Limit(size int32) *StmtSelect
- func (s StmtSelect) Modifier(modifiers ...string) *StmtSelect
- func (s StmtSelect) Offset(offset int32) *StmtSelect
- func (s StmtSelect) OrderAscBy(canExpr CanExpr) *StmtSelect
- func (s StmtSelect) OrderBy(canExpr CanExpr, orderType OrderType) *StmtSelect
- func (s StmtSelect) OrderDescBy(canExpr CanExpr) *StmtSelect
- func (s *StmtSelect) Type() StmtType
- func (s StmtSelect) Where(cond *Condition) *StmtSelect
- func (s StmtSelect) WithRollup() *StmtSelect
- type StmtType
- type StmtUpdate
- func (s StmtUpdate) Comment(comment string) *StmtUpdate
- func (s *StmtUpdate) Expr() *Expression
- func (s StmtUpdate) Limit(size int32) *StmtUpdate
- func (s StmtUpdate) Modifier(modifiers ...string) *StmtUpdate
- func (s StmtUpdate) OrderAscBy(col *Column) *StmtUpdate
- func (s StmtUpdate) OrderBy(col *Column, orderType OrderType) *StmtUpdate
- func (s StmtUpdate) OrderDescBy(col *Column) *StmtUpdate
- func (s StmtUpdate) Set(assignments ...*Assignment) *StmtUpdate
- func (s *StmtUpdate) Type() StmtType
- func (s StmtUpdate) Where(cond *Condition) *StmtUpdate
- type Table
- func (t *Table) AssignsByFieldValues(fieldValues FieldValues) (assignments Assignments)
- func (t *Table) ColumnsAndValuesByFieldValues(fieldValues FieldValues) (columns Columns, args []interface{})
- func (t *Table) Cond(query string, args ...interface{}) *Condition
- func (t *Table) Create(ifNotExists bool) *Stmt
- func (t Table) Define(defs ...TableDef) *Table
- func (t *Table) Delete() *StmtDelete
- func (t *Table) Diff(table *Table) *Stmt
- func (t *Table) Drop() *Stmt
- func (t *Table) Ex(query string, args ...interface{}) *Expression
- func (t *Table) FullName() string
- func (t *Table) Insert() *StmtInsert
- func (t *Table) Select() *StmtSelect
- func (t *Table) String() string
- func (t *Table) Truncate() *Stmt
- func (t *Table) Update() *StmtUpdate
- type TableDef
- type Tables
Constants ¶
View Source
const ( PRIMARY keyType = "PRIMARY" INDEX keyType = "INDEX" UNIQUE_INDEX keyType = "UNIQUE INDEX" )
Variables ¶
View Source
var Configuration = &struct { DropColumnWhenMigration bool }{}
View Source
var (
DeleteNeedLimitByWhere = fmt.Errorf("no where limit for delete")
)
View Source
var (
InsertValuesLengthNotMatch = fmt.Errorf("value length is not equal Col length")
)
View Source
var (
UpdateNeedLimitByWhere = fmt.Errorf("no where limit for update")
)
Functions ¶
func HolderRepeat ¶
Types ¶
type Assignment ¶
type Assignment Expression
func (Assignment) Expr ¶
func (a Assignment) Expr() *Expression
type Assignments ¶
type Assignments []*Assignment
func (Assignments) Expr ¶
func (assigns Assignments) Expr() (e *Expression)
type CanExpr ¶
type CanExpr interface {
Expr() *Expression
}
type Column ¶
type Column struct { Table *Table Name string FieldName string data_type.ColumnType }
func (*Column) Add ¶
func (c *Column) Add() *Expression
func (*Column) By ¶
func (c *Column) By(v interface{}) *Assignment
func (Column) Def ¶
func (c Column) Def() *Expression
func (*Column) Desc ¶
func (c *Column) Desc(d int) *Expression
func (*Column) Drop ¶
func (c *Column) Drop() *Expression
func (*Column) Expr ¶
func (c *Column) Expr() *Expression
func (*Column) Incr ¶
func (c *Column) Incr(d int) *Expression
func (*Column) IsValidDef ¶
func (*Column) Modify ¶
func (c *Column) Modify() *Expression
func (*Column) NotBetween ¶
type Columns ¶
type Columns struct {
// contains filtered or unexported fields
}
func (*Columns) AutoIncrement ¶
func (Columns) Expr ¶
func (cols Columns) Expr() (e *Expression)
func (*Columns) FieldNames ¶
func (Columns) Wrap ¶
func (cols Columns) Wrap() (e *Expression)
type CondRules ¶
type CondRules struct {
// contains filtered or unexported fields
}
func NewCondRules ¶
func NewCondRules() *CondRules
type Condition ¶
type Condition Expression
func (*Condition) Expr ¶
func (c *Condition) Expr() *Expression
type Expression ¶
func Expr ¶
func Expr(query string, args ...interface{}) *Expression
func ExprErr ¶
func ExprErr(err error) *Expression
func ExprFrom ¶
func ExprFrom(v interface{}) *Expression
func (Expression) ConcatBy ¶
func (e Expression) ConcatBy(joiner string, canExpr CanExpr) *Expression
func (*Expression) Expr ¶
func (e *Expression) Expr() *Expression
type FieldValues ¶
type FieldValues map[string]interface{}
type Function ¶
type Function struct { Name string // contains filtered or unexported fields }
func (*Function) Expr ¶
func (f *Function) Expr() *Expression
type Key ¶
func PrimaryKey ¶
func PrimaryKey() *Key
func UniqueIndex ¶
func (*Key) Add ¶
func (key *Key) Add() *Expression
func (*Key) Def ¶
func (key *Key) Def() *Expression
func (*Key) Drop ¶
func (key *Key) Drop() *Expression
func (*Key) IsValidDef ¶
type StmtDelete ¶
type StmtDelete struct {
// contains filtered or unexported fields
}
func Delete ¶
func Delete(table *Table) *StmtDelete
func (StmtDelete) AscendBy ¶
func (s StmtDelete) AscendBy(col *Column) *StmtDelete
func (StmtDelete) Comment ¶
func (s StmtDelete) Comment(comment string) *StmtDelete
func (StmtDelete) DescendBy ¶
func (s StmtDelete) DescendBy(col *Column) *StmtDelete
func (*StmtDelete) Expr ¶
func (s *StmtDelete) Expr() *Expression
func (StmtDelete) Limit ¶
func (s StmtDelete) Limit(size int32) *StmtDelete
func (StmtDelete) Modifier ¶
func (s StmtDelete) Modifier(modifiers ...string) *StmtDelete
func (StmtDelete) OrderBy ¶
func (s StmtDelete) OrderBy(col *Column, orderType OrderType) *StmtDelete
func (*StmtDelete) Type ¶
func (s *StmtDelete) Type() StmtType
func (StmtDelete) Where ¶
func (s StmtDelete) Where(cond *Condition) *StmtDelete
type StmtInsert ¶
type StmtInsert struct { Assignments // contains filtered or unexported fields }
func Insert ¶
func Insert(table *Table) *StmtInsert
func (StmtInsert) Columns ¶
func (s StmtInsert) Columns(cols Columns) *StmtInsert
func (StmtInsert) Comment ¶
func (s StmtInsert) Comment(comment string) *StmtInsert
func (*StmtInsert) Expr ¶
func (s *StmtInsert) Expr() *Expression
func (StmtInsert) Modifier ¶
func (s StmtInsert) Modifier(modifiers ...string) *StmtInsert
func (StmtInsert) OnDuplicateKeyUpdate ¶
func (s StmtInsert) OnDuplicateKeyUpdate(assigns ...*Assignment) *StmtInsert
func (*StmtInsert) Type ¶
func (s *StmtInsert) Type() StmtType
func (StmtInsert) Values ¶
func (s StmtInsert) Values(values ...interface{}) *StmtInsert
type StmtSelect ¶
type StmtSelect struct {
// contains filtered or unexported fields
}
func SelectFrom ¶
func SelectFrom(table *Table) *StmtSelect
func (StmtSelect) Comment ¶
func (s StmtSelect) Comment(comment string) *StmtSelect
func (*StmtSelect) Expr ¶
func (s *StmtSelect) Expr() *Expression
func (StmtSelect) For ¶
func (s StmtSelect) For(expr CanExpr) *StmtSelect
func (StmtSelect) ForUpdate ¶
func (s StmtSelect) ForUpdate() *StmtSelect
func (StmtSelect) GroupAscBy ¶
func (s StmtSelect) GroupAscBy(canExpr CanExpr) *StmtSelect
func (StmtSelect) GroupBy ¶
func (s StmtSelect) GroupBy(canExpr CanExpr) *StmtSelect
func (StmtSelect) GroupDescBy ¶
func (s StmtSelect) GroupDescBy(canExpr CanExpr) *StmtSelect
func (StmtSelect) Having ¶
func (s StmtSelect) Having(cond *Condition) *StmtSelect
func (StmtSelect) Limit ¶
func (s StmtSelect) Limit(size int32) *StmtSelect
func (StmtSelect) Modifier ¶
func (s StmtSelect) Modifier(modifiers ...string) *StmtSelect
func (StmtSelect) Offset ¶
func (s StmtSelect) Offset(offset int32) *StmtSelect
func (StmtSelect) OrderAscBy ¶
func (s StmtSelect) OrderAscBy(canExpr CanExpr) *StmtSelect
func (StmtSelect) OrderBy ¶
func (s StmtSelect) OrderBy(canExpr CanExpr, orderType OrderType) *StmtSelect
func (StmtSelect) OrderDescBy ¶
func (s StmtSelect) OrderDescBy(canExpr CanExpr) *StmtSelect
func (*StmtSelect) Type ¶
func (s *StmtSelect) Type() StmtType
func (StmtSelect) Where ¶
func (s StmtSelect) Where(cond *Condition) *StmtSelect
func (StmtSelect) WithRollup ¶
func (s StmtSelect) WithRollup() *StmtSelect
type StmtUpdate ¶
type StmtUpdate struct { Assignments // contains filtered or unexported fields }
func Update ¶
func Update(table *Table) *StmtUpdate
func (StmtUpdate) Comment ¶
func (s StmtUpdate) Comment(comment string) *StmtUpdate
func (*StmtUpdate) Expr ¶
func (s *StmtUpdate) Expr() *Expression
func (StmtUpdate) Limit ¶
func (s StmtUpdate) Limit(size int32) *StmtUpdate
func (StmtUpdate) Modifier ¶
func (s StmtUpdate) Modifier(modifiers ...string) *StmtUpdate
func (StmtUpdate) OrderAscBy ¶
func (s StmtUpdate) OrderAscBy(col *Column) *StmtUpdate
func (StmtUpdate) OrderBy ¶
func (s StmtUpdate) OrderBy(col *Column, orderType OrderType) *StmtUpdate
func (StmtUpdate) OrderDescBy ¶
func (s StmtUpdate) OrderDescBy(col *Column) *StmtUpdate
func (StmtUpdate) Set ¶
func (s StmtUpdate) Set(assignments ...*Assignment) *StmtUpdate
func (*StmtUpdate) Type ¶
func (s *StmtUpdate) Type() StmtType
func (StmtUpdate) Where ¶
func (s StmtUpdate) Where(cond *Condition) *StmtUpdate
type Table ¶
func (*Table) AssignsByFieldValues ¶
func (t *Table) AssignsByFieldValues(fieldValues FieldValues) (assignments Assignments)
func (*Table) ColumnsAndValuesByFieldValues ¶
func (t *Table) ColumnsAndValuesByFieldValues(fieldValues FieldValues) (columns Columns, args []interface{})
func (*Table) Delete ¶
func (t *Table) Delete() *StmtDelete
func (*Table) Ex ¶
func (t *Table) Ex(query string, args ...interface{}) *Expression
func (*Table) Insert ¶
func (t *Table) Insert() *StmtInsert
func (*Table) Select ¶
func (t *Table) Select() *StmtSelect
func (*Table) Update ¶
func (t *Table) Update() *StmtUpdate
type TableDef ¶
type TableDef interface { IsValidDef() bool Def() *Expression }
Click to show internal directories.
Click to hide internal directories.