Documentation ¶
Index ¶
- Variables
- func BuildDelete(table string, where map[string]interface{}) (string, []interface{}, error)
- func BuildInsert(table string, data []map[string]interface{}) (string, []interface{}, error)
- func BuildInsertIgnore(table string, data []map[string]interface{}) (string, []interface{}, error)
- func BuildReplaceInsert(table string, data []map[string]interface{}) (string, []interface{}, error)
- func BuildSelect(table string, where map[string]interface{}, selectField []string) (cond string, vals []interface{}, err error)
- func BuildUpdate(table string, where map[string]interface{}, update map[string]interface{}) (string, []interface{}, error)
- func NamedQuery(sql string, data map[string]interface{}) (string, []interface{}, error)
- func OmitEmpty(where map[string]interface{}, omitKey []string) map[string]interface{}
- type AggregateSymbleBuilder
- type Between
- type Comparable
- type Eq
- type Gt
- type Gte
- type In
- type Like
- type Lt
- type Lte
- type Ne
- type NotBetween
- type NotIn
- type NotLike
- type NullType
- type ResultResolver
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnsupportedOperator reports there's unsupported operators in where-condition ErrUnsupportedOperator = errors.New("[builder] unsupported operator") )
Functions ¶
func BuildDelete ¶
BuildDelete work as its name says
func BuildInsert ¶
BuildInsert work as its name says
func BuildInsertIgnore ¶ added in v1.1.0
BuildInsertIgnore work as its name says
func BuildReplaceInsert ¶ added in v1.1.0
BuildReplaceInsert work as its name says
func BuildSelect ¶
func BuildSelect(table string, where map[string]interface{}, selectField []string) (cond string, vals []interface{}, err error)
BuildSelect work as its name says. supported operators including: =,in,>,>=,<,<=,<>,!=. key without operator will be regarded as =. special key begin with _: _orderby,_groupby,_limit,_having. the value of _orderby must be a string separated by a space(ie:map[string]interface{}{"_orderby": "fieldName desc"}). the value of _limit must be a slice whose type should be []uint and must contain two uints(ie: []uint{0, 100}). the value of _having must be a map just like where but only support =,in,>,>=,<,<=,<>,!= for more examples,see README.md or open a issue.
func BuildUpdate ¶
func BuildUpdate(table string, where map[string]interface{}, update map[string]interface{}) (string, []interface{}, error)
BuildUpdate work as its name says
func NamedQuery ¶
NamedQuery is used for expressing complex query
Types ¶
type AggregateSymbleBuilder ¶
type AggregateSymbleBuilder interface {
Symble() string
}
AggregateSymbleBuilder need to be implemented so that executor can get what should be put into `select Symble() from xxx where yyy`
func AggregateCount ¶
func AggregateCount(col string) AggregateSymbleBuilder
AggregateCount count(col)
type Comparable ¶
type Comparable interface {
Build() ([]string, []interface{})
}
Comparable requires type implements the Build method
type NotBetween ¶ added in v1.2.0
type NotBetween map[string][]interface{}
func (NotBetween) Build ¶ added in v1.2.0
func (nbt NotBetween) Build() ([]string, []interface{})
type NullType ¶
type NullType byte
NullType is the NULL type in mysql
const ( // IsNull the same as `is null` IsNull NullType // IsNotNull the same as `is not null` IsNotNull )
type ResultResolver ¶
ResultResolver is a helper for retrieving data caller should know the type and call the responding method
func AggregateQuery ¶
func AggregateQuery(ctx context.Context, db *sql.DB, table string, where map[string]interface{}, aggregate AggregateSymbleBuilder) (ResultResolver, error)
AggregateQuery is a helper function to execute the aggregate query and return the result