Documentation
¶
Index ¶
- type Expr
- func And(conds ...Expr) Expr
- func Arg(val any) Expr
- func As(in Expr, out string) Expr
- func ColumnAs(in, out string) Expr
- func Columns(cols ...string) Expr
- func Count(cols ...string) Expr
- func Eq(a, b Expr) Expr
- func Exprs(e ...Expr) Expr
- func Geq(a, b Expr) Expr
- func Gt(a, b Expr) Expr
- func Ident(s string) Expr
- func In(a, b Expr) Expr
- func Is(a, b Expr) Expr
- func IsNot(a, b Expr) Expr
- func Leq(a, b Expr) Expr
- func Like(a, b Expr) Expr
- func List(vals ...any) Expr
- func Lit(val any) Expr
- func Lower(expr Expr) Expr
- func Lt(a, b Expr) Expr
- func Neq(a, b Expr) Expr
- func NotIn(a, b Expr) Expr
- func Or(conds ...Expr) Expr
- func Sum(expr Expr) Expr
- type Option
- func From(table string) Option
- func FromAs(table, alias string) Option
- func Join(table string, expr Expr) Option
- func Limit(n int64) Option
- func Offset(n int64) Option
- func Options(opts ...Option) Option
- func OrWhere(expr Expr) Option
- func OrWhereEq(col string, expr Expr) Option
- func OrWhereGeq(col string, expr Expr) Option
- func OrWhereGt(col string, expr Expr) Option
- func OrWhereIn(col string, expr Expr) Option
- func OrWhereIs(col string, expr Expr) Option
- func OrWhereIsNil(col string) Option
- func OrWhereIsNot(col string, expr Expr) Option
- func OrWhereIsNotNil(col string) Option
- func OrWhereLeq(col string, expr Expr) Option
- func OrWhereLt(col string, expr Expr) Option
- func OrWhereNotEq(col string, expr Expr) Option
- func OrWhereNotIn(col string, expr Expr) Option
- func OrderAsc(cols ...string) Option
- func OrderDesc(cols ...string) Option
- func Returning(cols ...string) Option
- func Set(col string, expr Expr) Option
- func Values(vals ...any) Option
- func Where(expr Expr) Option
- func WhereEq(col string, expr Expr) Option
- func WhereGeq(col string, expr Expr) Option
- func WhereGt(col string, expr Expr) Option
- func WhereIn(col string, expr Expr) Option
- func WhereIs(col string, expr Expr) Option
- func WhereIsNil(col string) Option
- func WhereIsNot(col string, expr Expr) Option
- func WhereIsNotNil(col string) Option
- func WhereLeq(col string, expr Expr) Option
- func WhereLike(col string, expr Expr) Option
- func WhereLt(col string, expr Expr) Option
- func WhereNotEq(col string, expr Expr) Option
- func WhereNotIn(col string, expr Expr) Option
- type Query
- func Delete(table string, opts ...Option) *Query
- func Insert(table string, expr Expr, opts ...Option) *Query
- func Select(expr Expr, opts ...Option) *Query
- func SelectDistinct(expr Expr, opts ...Option) *Query
- func SelectDistinctOn(expr1, expr2 Expr, opts ...Option) *Query
- func Union(queries ...*Query) *Query
- func Update(table string, opts ...Option) *Query
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Expr ¶
Expr represents an SQL expression.
Args returns the list of arguments the SQL expression has. This is used to correctly handle the parameter binding of dynamic arguments into a query. It is valid for this to return nil.
Build returns the SQL code that represents the expression.
func Arg ¶
Arg turns the given value into an argument expression. This would be used for passing user provided values into a query that should be bound to parameters.
func As ¶
As specifies an AS expression on the given expression. For example,
query.As(query.Count("id"), "id_count")
func Columns ¶
Columns turns the given strings into a list expression of column names. This would be used to control which columns should be retrieved as part of a SELECT query.
Calling this function is no different than calling query.List and passing multiple query.Ident expressions, for example,
query.List(query.Ident("id"), query.Ident("email"))
The main difference is that the above will return an expression wrapped in a pair of parentheses. This is still valid SQL code, this function simply exists for ease of use.
func Exprs ¶
Exprs turns the list of expressions into a single expression. When built the expressions will be separated by the string ", ".
func Ident ¶
Ident turns the given string into an identifier expression. This would be used for referring directly to a column name in SQL.
For example,
query.Join("users", query.Eq(query.Ident("posts.user_id"), query.Ident("users.id")))
becomes,
JOIN users ON posts.user_id = users.id
func List ¶
List turns the given values into a list expression. If the given values are lists then they will be wrapped appropriately. If the given values are literal expressions, then they will end up in the built SQL code verbatim and not as placeholders.
func Lit ¶
Lit turns the given value in a literal expression. This is passed directly through into the query, and does not use a parameter binding for it.
type Option ¶
func OrWhereGeq ¶
func OrWhereIsNil ¶
func OrWhereIsNot ¶
func OrWhereIsNotNil ¶
func OrWhereLeq ¶
func OrWhereNotEq ¶
func OrWhereNotIn ¶
func WhereIsNil ¶
func WhereIsNot ¶
func WhereIsNotNil ¶
func WhereNotEq ¶
func WhereNotIn ¶
type Query ¶
type Query struct {
// contains filtered or unexported fields
}