Documentation
¶
Index ¶
- func And(exps ...expr.Expr) expr.Expr
- func Avg(col string, alias_table ...string) expr.Expr
- func Between(col string, from, to interface{}) expr.Expr
- func Count(col string, alias_table ...string) expr.Expr
- func Eq(col string, val interface{}) expr.Expr
- func Exists(exp expr.Expr) expr.Expr
- func In(col string, values ...interface{}) expr.Expr
- func Like(col string, value string) expr.LikeExp
- func Max(col string, alias_table ...string) expr.Expr
- func Min(col string, alias_table ...string) expr.Expr
- func Not(e expr.Expr) expr.Expr
- func NotBetween(col string, from, to interface{}) expr.Expr
- func NotExists(exp expr.Expr) expr.Expr
- func NotIn(col string, values ...interface{}) expr.Expr
- func NotLike(col string, value string) expr.LikeExp
- func Op(col string, op string, val interface{}) expr.Expr
- func Or(exps ...expr.Expr) expr.Expr
- func StaticEq(col1 string, col2 string) expr.Expr
- func StaticOp(col1 string, op string, col2 string) expr.Expr
- func Sum(col string, alias_table ...string) expr.Expr
- type DB
- type Tx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Between ¶
Between generates a BETWEEN expression. For example, Between("age", 10, 30) generates: "age" BETWEEN 10 AND 30
func Count ¶
Count generates a COUNT() expression For example:
Count("id"): Count(id)
Count("id","id_count"): Count(id) AS id_count
Count("id","id_count","user"): Count(user.id) AS id_count
func In ¶
In generates an IN expression for the specified column and the list of allowed values. If values is empty, a SQL "0=1" will be generated which represents a false expression.
func Like ¶
Like generates a LIKE expression for the specified column and the possible strings that the column should be like. If multiple values are present, the column should be like *all* of them. For example, Like("name", "key", "word") will generate a SQL expression: "name" LIKE "%key%" AND "name" LIKE "%word%".
func NotBetween ¶
NotBetween generates a NOT BETWEEN expression. For example, NotBetween("age", 10, 30) generates: "age" NOT BETWEEN 10 AND 30
func NotExists ¶
NotExists generates an EXISTS expression by prefixing "NOT EXISTS" to the given expression.
func NotIn ¶
NotIn generates an NOT IN expression for the specified column and the list of disallowed values. If values is empty, an empty string will be returned indicating a true expression.
func NotLike ¶
NotLike generates a NOT LIKE expression. For example, NotLike("name", "key", "word") will generate a SQL expression: "name" NOT LIKE "%key%" AND "name" NOT LIKE "%word%". Please see Like() for more details.
Types ¶
type DB ¶
DB enhances sql.DB by providing a set of DB-agnostic query building methods. DB allows easier query building and population of data into Go variables.
func Open ¶
Open opens a database specified by a driver name and data source name (DSN). Note that Open does not check if DSN is specified correctly. It doesn't try to establish a DB connection either. Please refer to sql.Open() for more information.
func OpenWithDB ¶
OpenWithDB Create a new DB instance. Note that Open does not check if DSN is specified correctly. It doesn't try to establish a DB connection either. Please refer to sql.Open() for more information.