42 lines
764 B
Go
42 lines
764 B
Go
|
package storage
|
||
|
|
||
|
type OrderDirection string
|
||
|
|
||
|
const (
|
||
|
OrderDirectionAsc OrderDirection = "ASC"
|
||
|
OrderDirectionDesc OrderDirection = "DESC"
|
||
|
)
|
||
|
|
||
|
type QueryOption struct {
|
||
|
Limit *int
|
||
|
Offset *int
|
||
|
OrderBy *string
|
||
|
OrderDirection *OrderDirection
|
||
|
}
|
||
|
|
||
|
type QueryOptionFunc func(o *QueryOption)
|
||
|
|
||
|
func WithLimit(limit int) QueryOptionFunc {
|
||
|
return func(o *QueryOption) {
|
||
|
o.Limit = &limit
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func WithOffset(offset int) QueryOptionFunc {
|
||
|
return func(o *QueryOption) {
|
||
|
o.Offset = &offset
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func WithOrderBy(orderBy string) QueryOptionFunc {
|
||
|
return func(o *QueryOption) {
|
||
|
o.OrderBy = &orderBy
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func WithOrderDirection(direction OrderDirection) QueryOptionFunc {
|
||
|
return func(o *QueryOption) {
|
||
|
o.OrderDirection = &direction
|
||
|
}
|
||
|
}
|