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