/
githubmirror
/
pop
Обзор
Документация
Войти
/
githubmirror
/
pop
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
scopes.go
38 строк
903 B
Mark Bates
Revert "initial port from pop/fizz to fizz"
16 июн 2018, 22:28
16 июн 2018, 22:28
5d13e5e
Код
Авторство
О чём код?
package pop // ScopeFunc applies a custom operation on a given `Query` type ScopeFunc func(q *Query) *Query // Scope the query by using a `ScopeFunc` // // func ByName(name string) ScopeFunc { // return func(q *Query) *Query { // return q.Where("name = ?", name) // } // } // // func WithDeleted(q *pop.Query) *pop.Query { // return q.Where("deleted_at is null") // } // // c.Scope(ByName("mark)).Scope(WithDeleted).First(&User{}) func (q *Query) Scope(sf ScopeFunc) *Query { return sf(q) } // Scope the query by using a `ScopeFunc` // // func ByName(name string) ScopeFunc { // return func(q *Query) *Query { // return q.Where("name = ?", name) // } // } // // func WithDeleted(q *pop.Query) *pop.Query { // return q.Where("deleted_at is null") // } // // c.Scope(ByName("mark)).Scope(WithDeleted).First(&User{}) func (c *Connection) Scope(sf ScopeFunc) *Query { return Q(c).Scope(sf) }