2016-04-19 04:02:32 +02:00
|
|
|
package qs
|
2016-04-13 15:51:58 +02:00
|
|
|
|
2016-06-08 07:45:34 +02:00
|
|
|
import "github.com/nullbio/sqlboiler/boil"
|
2016-04-13 15:51:58 +02:00
|
|
|
|
2016-04-19 04:02:32 +02:00
|
|
|
type QueryMod func(q *boil.Query)
|
|
|
|
|
2016-04-20 14:51:04 +02:00
|
|
|
func Apply(q *boil.Query, mods ...QueryMod) {
|
|
|
|
for _, mod := range mods {
|
|
|
|
mod(q)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-02 23:07:51 +02:00
|
|
|
func Or(whereMods ...QueryMod) QueryMod {
|
|
|
|
return func(q *boil.Query) {
|
|
|
|
if len(whereMods) < 2 {
|
|
|
|
// error, needs to be at least 2 for an or
|
|
|
|
}
|
|
|
|
// add the where mods to query with or seperators
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-19 07:31:07 +02:00
|
|
|
func Limit(limit int) QueryMod {
|
|
|
|
return func(q *boil.Query) {
|
|
|
|
boil.SetLimit(q, limit)
|
2016-04-13 15:51:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-19 07:31:07 +02:00
|
|
|
func InnerJoin(on string, args ...interface{}) QueryMod {
|
|
|
|
return func(q *boil.Query) {
|
|
|
|
boil.SetInnerJoin(q, on, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func OuterJoin(on string, args ...interface{}) QueryMod {
|
|
|
|
return func(q *boil.Query) {
|
|
|
|
boil.SetOuterJoin(q, on, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func LeftOuterJoin(on string, args ...interface{}) QueryMod {
|
2016-04-19 04:02:32 +02:00
|
|
|
return func(q *boil.Query) {
|
2016-04-19 07:31:07 +02:00
|
|
|
boil.SetLeftOuterJoin(q, on, args...)
|
2016-04-13 15:51:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-19 07:31:07 +02:00
|
|
|
func RightOuterJoin(on string, args ...interface{}) QueryMod {
|
2016-04-19 04:02:32 +02:00
|
|
|
return func(q *boil.Query) {
|
2016-04-19 07:31:07 +02:00
|
|
|
boil.SetRightOuterJoin(q, on, args...)
|
2016-04-16 09:25:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func Select(columns ...string) QueryMod {
|
2016-04-19 04:02:32 +02:00
|
|
|
return func(q *boil.Query) {
|
2016-04-19 07:31:07 +02:00
|
|
|
boil.SetSelect(q, columns...)
|
2016-04-16 09:25:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-13 15:51:58 +02:00
|
|
|
func Where(clause string, args ...interface{}) QueryMod {
|
2016-04-19 04:02:32 +02:00
|
|
|
return func(q *boil.Query) {
|
2016-04-19 07:31:07 +02:00
|
|
|
boil.SetWhere(q, clause, args...)
|
2016-04-13 15:51:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func GroupBy(clause string) QueryMod {
|
2016-04-19 04:02:32 +02:00
|
|
|
return func(q *boil.Query) {
|
2016-04-19 07:31:07 +02:00
|
|
|
boil.SetGroupBy(q, clause)
|
2016-04-13 15:51:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func OrderBy(clause string) QueryMod {
|
2016-04-19 04:02:32 +02:00
|
|
|
return func(q *boil.Query) {
|
2016-04-19 07:31:07 +02:00
|
|
|
boil.SetOrderBy(q, clause)
|
2016-04-13 15:51:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func Having(clause string) QueryMod {
|
2016-04-19 04:02:32 +02:00
|
|
|
return func(q *boil.Query) {
|
2016-04-19 07:31:07 +02:00
|
|
|
boil.SetHaving(q, clause)
|
2016-04-13 15:51:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-26 11:27:00 +02:00
|
|
|
func Table(table string) QueryMod {
|
2016-04-19 04:02:32 +02:00
|
|
|
return func(q *boil.Query) {
|
2016-04-26 11:27:00 +02:00
|
|
|
boil.SetTable(q, table)
|
2016-04-13 15:51:58 +02:00
|
|
|
}
|
|
|
|
}
|