Documentation ¶
Index ¶
- func Apply(q *queries.Query, mods ...QueryMod)
- func Rels(r ...string) string
- type QueryMod
- func And(clause string, args ...interface{}) QueryMod
- func AndIn(clause string, args ...interface{}) QueryMod
- func Distinct(clause string) QueryMod
- func Expr(wheremods ...QueryMod) QueryMod
- func For(clause string) QueryMod
- func From(from string) QueryMod
- func FullOuterJoin(clause string, args ...interface{}) QueryMod
- func GroupBy(clause string) QueryMod
- func Having(clause string, args ...interface{}) QueryMod
- func InnerJoin(clause string, args ...interface{}) QueryMod
- func LeftOuterJoin(clause string, args ...interface{}) QueryMod
- func Limit(limit int) QueryMod
- func Load(relationship string, mods ...QueryMod) QueryMod
- func Offset(offset int) QueryMod
- func Or(clause string, args ...interface{}) QueryMod
- func Or2(q QueryMod) QueryMod
- func OrIn(clause string, args ...interface{}) QueryMod
- func OrderBy(clause string) QueryMod
- func RightOuterJoin(clause string, args ...interface{}) QueryMod
- func SQL(sql string, args ...interface{}) QueryMod
- func Select(columns ...string) QueryMod
- func Where(clause string, args ...interface{}) QueryMod
- func WhereIn(clause string, args ...interface{}) QueryMod
- func With(clause string, args ...interface{}) QueryMod
- type QueryModFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type QueryMod ¶
QueryMod modifies a query object.
func And ¶
And allows you to specify a where clause separated by an AND for your statement And is a duplicate of the Where function, but allows for more natural looking query mod chains, for example: (Where("a=?"), And("b=?"), Or("c=?")))
Because Where statements are by default combined with and, there's no reason to call this method as it behaves the same as "Where"
func AndIn ¶
AndIn allows you to specify a "x IN (set)" clause separated by an AndIn for your where statement. AndIn is a duplicate of the WhereIn function, but allows for more natural looking query mod chains, for example: (WhereIn("column1 in ?"), AndIn("column2 in ?"), OrIn("column3 in ?"))
func Expr ¶
Expr groups where query mods. It's detrimental to use this with any other type of Query Mod because the effects will always only affect where clauses.
When Expr is used, the entire query will stop doing automatic paretheses for the where statement and you must use Expr anywhere you would like them.
Do NOT use with anything except where.
func FullOuterJoin ¶
FullOuterJoin on another table
func LeftOuterJoin ¶
LeftOuterJoin on another table
func Load ¶
Load allows you to specify foreign key relationships to eager load for your query. Passed in relationships need to be in the format MyThing or MyThings. Relationship name plurality is important, if your relationship is singular, you need to specify the singular form and vice versa.
In the following example we see how to eager load a users's videos and the video's tags comments, and publisher during a query to find users.
models.Users(qm.Load("Videos.Tags"))
In order to filter better on the query for the relationships you can additionally supply query mods.
models.Users(qm.Load("Videos.Tags", Where("deleted = ?", isDeleted)))
Keep in mind the above only sets the query mods for the query on the last specified relationship. In this case, only Tags will get the query mod. If you want to do intermediate relationships with query mods you must specify them separately:
models.Users( qm.Load("Videos", Where("deleted = false")) qm.Load("Videos.Tags", Where("deleted = ?", isDeleted)) )
func Or2 ¶
Or2 takes a Where query mod and turns it into an Or. It can be detrimental if used on things that are not Where query mods as it will still modify the last Where statement into an Or.
func RightOuterJoin ¶
RightOuterJoin on another table
func Where ¶
Where allows you to specify a where clause for your statement. If multiple Where statements are used they are combined with 'and'
type QueryModFunc ¶
The QueryModFunc type is an adapter to allow the use of ordinary functions for query modifying. If f is a function with the appropriate signature, QueryModFunc(f) is a QueryMod that calls f.