edge/pkg/storage/query_options.go

42 lines
770 B
Go
Raw Permalink Normal View History

2023-02-09 12:16:36 +01:00
package storage
type OrderDirection string
const (
OrderDirectionAsc OrderDirection = "ASC"
OrderDirectionDesc OrderDirection = "DESC"
)
type QueryOptions struct {
2023-02-09 12:16:36 +01:00
Limit *int
Offset *int
OrderBy *string
OrderDirection *OrderDirection
}
type QueryOptionFunc func(o *QueryOptions)
2023-02-09 12:16:36 +01:00
func WithLimit(limit int) QueryOptionFunc {
return func(o *QueryOptions) {
2023-02-09 12:16:36 +01:00
o.Limit = &limit
}
}
func WithOffset(offset int) QueryOptionFunc {
return func(o *QueryOptions) {
2023-02-09 12:16:36 +01:00
o.Offset = &offset
}
}
func WithOrderBy(orderBy string) QueryOptionFunc {
return func(o *QueryOptions) {
2023-02-09 12:16:36 +01:00
o.OrderBy = &orderBy
}
}
func WithOrderDirection(direction OrderDirection) QueryOptionFunc {
return func(o *QueryOptions) {
2023-02-09 12:16:36 +01:00
o.OrderDirection = &direction
}
}