edge/pkg/storage/query_option.go

42 lines
764 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 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
}
}