sqlboiler/boil/query_mods.go
Patrick O'brien d89d23e673 Began implementing the ORM prototype
* Hooks, query mods, and query
* Update and UpdateX
2016-04-13 23:51:58 +10:00

56 lines
876 B
Go

package boil
type QueryMod func(q *Query)
func (q *Query) Apply(mods ...QueryMod) {
for _, mod := range mods {
mod(q)
}
}
func DB(e Executor) QueryMod {
return func(q *Query) {
q.executor = e
}
}
func Limit(limit int) QueryMod {
return func(q *Query) {
q.limit = limit
}
}
func Where(clause string, args ...interface{}) QueryMod {
return func(q *Query) {
w := where{
clause: clause,
args: args,
}
q.where = append(q.where, w)
}
}
func GroupBy(clause string) QueryMod {
return func(q *Query) {
q.groupBy = append(q.groupBy, clause)
}
}
func OrderBy(clause string) QueryMod {
return func(q *Query) {
q.orderBy = append(q.orderBy, clause)
}
}
func Having(clause string) QueryMod {
return func(q *Query) {
q.having = append(q.having, clause)
}
}
func From(clause string) QueryMod {
return func(q *Query) {
q.from = clause
}
}