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 AndNotIn(clause string, args ...interface{}) QueryMod
- func Comment(comment string) 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 LoadJoined() 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 OrNotIn(clause string, args ...interface{}) QueryMod
- func OrderBy(clause string, args ...interface{}) 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 WhereNotIn(clause string, args ...interface{}) QueryMod
- func With(clause string, args ...interface{}) QueryMod
- func WithDeleted() 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 AndNotIn ¶
AndNotIn allows you to specify a "x NOT IN (set)" clause separated by an AndNotIn for your where statement. AndNotIn is a duplicate of the WhereNotIn function, but allows for more natural looking query mod chains, for example: (WhereNotIn("column1 not in ?"), AndIn("column2 not in ?"), OrIn("column3 not 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 LoadJoined ¶
func LoadJoined() QueryMod
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 OrNotIn ¶
OrNotIn allows you to specify a NOT IN clause separated by an OR for your where statement
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'
func WhereIn ¶
WhereIn allows you to specify a "x IN (set)" clause for your where statement Example clauses: "column in ?", "(column1,column2) in ?"
func WhereNotIn ¶
WhereNotIn allows you to specify a "x NOT IN (set)" clause for your where statement. Example clauses: "column not in ?", "(column1,column2) not in ?"
func WithDeleted ¶ added in v4.6.0
func WithDeleted() QueryMod
WithDeleted removes where clauses that sqlboiler soft-delete may have placed in a query.
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.