Documentation ¶
Index ¶
- Constants
- Variables
- func FilterToQuery(f IFilter) (q map[string]interface{}, err error)
- func GetFilterAll(getKeyFn func(key string) string) (res bool, err error)
- func GetFilterQuery(getKeyFn func(key string) string, opts ...GetFilterQueryOption) (q map[string]interface{}, err error)
- func GetSorts(getKeyFn func(key string) string) (sorts []entity.Sort, err error)
- func GetSortsOption(getKeyFn func(key string) string) (sort bson.D, err error)
- func MustGetFilterAll(getKeyFn func(key string) string) (res bool)
- func MustGetFilterQuery(getKeyFn func(key string) string, opts ...GetFilterQueryOption) (q map[string]interface{})
- func MustGetSortOption(getKeyFn func(key string) string) (sort bson.D)
- func NewFilterError(msg string) (err error)
- func SortsToOption(sorts []entity.Sort) (sort bson.D, err error)
- type Condition
- type FieldSpecification
- type Filter
- type FilterCondition
- type GetFilterQueryOption
- type GetFilterQueryOptions
- type IFilter
Constants ¶
View Source
const ( FilterQueryFieldConditions = "conditions" FilterQueryFieldAll = "all" )
View Source
const ( FilterObjectTypeString = "string" FilterObjectTypeNumber = "number" FilterObjectTypeBoolean = "boolean" )
View Source
const ( FilterOpNotSet = "ns" FilterOpContains = "c" FilterOpNotContains = "nc" FilterOpRegex = "r" FilterOpEqual = "eq" FilterOpNotEqual = "ne" FilterOpIn = "in" FilterOpNotIn = "nin" FilterOpGreaterThan = "gt" FilterOpLessThan = "lt" FilterOpGreaterThanEqual = "gte" FilterOpLessThanEqual = "lte" FilterOpSearch = "s" )
View Source
const ( ASCENDING = "asc" DESCENDING = "dsc" )
View Source
const (
SortQueryField = "sort"
)
Variables ¶
View Source
var ErrorFilterInvalidOperation = NewFilterError("invalid operation")
View Source
var ErrorFilterUnableToParseQuery = NewFilterError("unable to parse query")
Functions ¶
func FilterToQuery ¶
FilterToQuery Translate entity.Filter to bson.M
func GetFilterAll ¶
GetFilterAll Get all
func GetFilterQuery ¶
func GetFilterQuery(getKeyFn func(key string) string, opts ...GetFilterQueryOption) (q map[string]interface{}, err error)
GetFilterQuery Get bson.M
func GetSortsOption ¶
GetSortsOption Get entity.Sort
func MustGetFilterAll ¶
func MustGetFilterQuery ¶
func MustGetFilterQuery(getKeyFn func(key string) string, opts ...GetFilterQueryOption) (q map[string]interface{})
func NewFilterError ¶
Types ¶
type Condition ¶
type FieldSpecification ¶
type FieldSpecification struct {
TypeIsString bool
}
type Filter ¶
type Filter struct { IsOr bool `form:"is_or" url:"is_or"` Conditions []*Condition `json:"conditions"` }
func GetFilter ¶
func GetFilter(getKeyFn func(key string) string, opts ...GetFilterQueryOption) (f *Filter, err error)
GetFilter Get entity.Filter
func (*Filter) GetConditions ¶
func (f *Filter) GetConditions() (conditions []FilterCondition)
func (*Filter) SetConditions ¶
func (f *Filter) SetConditions(conditions []FilterCondition)
type FilterCondition ¶
type GetFilterQueryOption ¶
type GetFilterQueryOption = func(options *GetFilterQueryOptions)
func GetFilterQueryOptionWithTypeIsString ¶
func GetFilterQueryOptionWithTypeIsString(fieldName string, fieldIsString bool) GetFilterQueryOption
force specify field type is string
type GetFilterQueryOptions ¶
type GetFilterQueryOptions struct {
SpecificationList map[string]*FieldSpecification
}
func (*GetFilterQueryOptions) FieldIsString ¶
func (o *GetFilterQueryOptions) FieldIsString(fieldName string) bool
func (*GetFilterQueryOptions) FieldSpecification ¶
func (o *GetFilterQueryOptions) FieldSpecification(fieldName string) *FieldSpecification
type IFilter ¶
type IFilter interface { GetIsOr() (isOr bool) SetIsOr(isOr bool) GetConditions() (conditions []FilterCondition) SetConditions(conditions []FilterCondition) IsNil() (ok bool) }
Click to show internal directories.
Click to hide internal directories.