Documentation ¶
Index ¶
- Constants
- Variables
- func AddNestedField(f, nested *FilterField)
- func FilterAppendValues(f *FilterField, values ...*OpValuePair)
- type FilterField
- func (f *FilterField) AddNestedField(nested *FilterField)
- func (f *FilterField) AddValues(values ...*OpValuePair)
- func (f *FilterField) Key() string
- func (f *FilterField) NestedFields() []*FilterField
- func (f *FilterField) Raw() string
- func (f *FilterField) SetValues(values []string, op *Operator, sup *i18n.Support) (errObj *aerrors.ApiError)
- func (f *FilterField) StructField() *models.StructField
- func (f *FilterField) Values() []*OpValuePair
- type OpValuePair
- type Operator
- type OperatorContainer
Constants ¶
const ( // logical filters AnnotationOperatorEqual = "$eq" AnnotationOperatorIn = "$in" AnnotationOperatorNotEqual = "$ne" AnnotationOperatorNotIn = "$notin" AnnotationOperatorGreaterThan = "$gt" AnnotationOperatorGreaterEqual = "$ge" AnnotationOperatorLessThan = "$lt" AnnotationOperatorLessEqual = "$le" AnnotationOperatorIsNull = "$isnull" AnnotationOperatorNotNull = "$notnull" AnnotationOperatorExists = "$exists" AnnotationOperatorNotExists = "$notexists" AnnotationOperatorContains = "$contains" AnnotationOperatorStartsWith = "$startswith" AnnotationOperatorEndsWith = "$endswith" AnnotationOperatorStDWithin = "$st_dwithin" )
Operators
Variables ¶
var ( // Logical Operators OpEqual = &Operator{Raw: AnnotationOperatorEqual, Name: "Equal"} OpIn = &Operator{Raw: AnnotationOperatorIn, Name: "In"} OpNotEqual = &Operator{Raw: AnnotationOperatorNotEqual, Name: "NotEqual"} OpNotIn = &Operator{Raw: AnnotationOperatorNotIn, Name: "NotIn"} OpGreaterThan = &Operator{Raw: AnnotationOperatorGreaterThan, Name: "GreaterThan"} OpGreaterEqual = &Operator{Raw: AnnotationOperatorGreaterEqual, Name: "GreaterThanOrEqualTo"} OpLessThan = &Operator{Raw: AnnotationOperatorLessThan, Name: "LessThan"} OpLessEqual = &Operator{Raw: AnnotationOperatorLessEqual, Name: "LessThanOrEqualTo"} // Strings Only operators OpContains = &Operator{Raw: AnnotationOperatorContains, Name: "Contains"} OpStartsWith = &Operator{Raw: AnnotationOperatorStartsWith, Name: "StartsWith"} OpEndsWith = &Operator{Raw: AnnotationOperatorEndsWith, Name: "EndsWith"} OpIsNull = &Operator{Raw: AnnotationOperatorIsNull, Name: "IsNull"} OpNotNull = &Operator{Raw: AnnotationOperatorNotNull, Name: "NotNull"} OpExists = &Operator{Raw: AnnotationOperatorExists, Name: "Exists"} OpNotExists = &Operator{Raw: AnnotationOperatorNotExists, Name: "NotExists"} )
Operator definitions
var Operators = NewOpContainer()
Operators contains all the registered operators
Functions ¶
func AddNestedField ¶
func AddNestedField(f, nested *FilterField)
AddNestedField adds nested filterfield for the filter 'f'
func FilterAppendValues ¶
func FilterAppendValues(f *FilterField, values ...*OpValuePair)
FilterAppendvalues adds the values to the given filter field
Types ¶
type FilterField ¶
type FilterField struct {
// contains filtered or unexported fields
}
FilterField is a field that contains information about filters
func CopyFilter ¶
func CopyFilter(f *FilterField) *FilterField
CopyFilter copies given FilterField with it's values
func GetOrCreateNestedFilter ¶
func GetOrCreateNestedFilter(f *FilterField, field interface{}) *FilterField
GetOrCreateNestedFilter gets the filter field for given field If the field is a key returns the filter by key
func NestedFields ¶
func NestedFields(f *FilterField) []*FilterField
func NewFilter ¶
func NewFilter(s *models.StructField, values ...*OpValuePair) *FilterField
NewFilter creates the filterField for given stuct field and values
func (*FilterField) AddNestedField ¶
func (f *FilterField) AddNestedField(nested *FilterField)
AddNestedField adds the nested field value
func (*FilterField) AddValues ¶
func (f *FilterField) AddValues(values ...*OpValuePair)
AddValues adds provided values to the filter values
func (*FilterField) NestedFields ¶
func (f *FilterField) NestedFields() []*FilterField
NestedFields returns nested fields for given filter
func (*FilterField) SetValues ¶
func (f *FilterField) SetValues( values []string, op *Operator, sup *i18n.Support, ) (errObj *aerrors.ApiError)
SetValues sets the filter values for provided field, it's operator and possible i18n Support
func (*FilterField) StructField ¶
func (f *FilterField) StructField() *models.StructField
StructField returns the filter's StructField
func (*FilterField) Values ¶
func (f *FilterField) Values() []*OpValuePair
Values return filter values
type OpValuePair ¶
type OpValuePair struct { Values []interface{} // contains filtered or unexported fields }
OpValuePair are the values used within the provided FilterField It contains the Values which is a slice of provided values for given 'Operator'
func CopyOpValuePair ¶
func CopyOpValuePair(o *OpValuePair) *OpValuePair
CopyOpValuePair copies operator value pair
func FilterOpValuePairs ¶
func FilterOpValuePairs(f *FilterField) []*OpValuePair
FilterOpValuePairs returns the values of the provided filter field.
func NewOpValuePair ¶
func NewOpValuePair(o *Operator, values ...interface{}) *OpValuePair
NewOpValuePair creates new operator value pair
func (*OpValuePair) Operator ¶
func (o *OpValuePair) Operator() *Operator
Operator gets the operator for OpValuePair
func (*OpValuePair) SetOperator ¶
func (o *OpValuePair) SetOperator(op *Operator)
SetOperator sets the operator for given opvalue pair
type Operator ¶
type Operator struct { // Id is the filter operator id used for comparing the operator type Id uint16 // Raw is the raw value of the current operator Raw string // Name is the human readable filter operator string value Name string }
Operator is the operator used while filtering the query
func (Operator) IsStandard ¶
IsStandard checks if the operator is standard
type OperatorContainer ¶
OperatorContainer is the container for the filter operators It registers new operators and checks if no operator with provided Raw value already exists inside.
func NewOpContainer ¶
func NewOpContainer() *OperatorContainer
NewOpContainer creates new container operator
func (*OperatorContainer) Get ¶
func (c *OperatorContainer) Get(raw string) (*Operator, bool)
Get gets the operator on the base of the raw value
func (*OperatorContainer) GetByName ¶
func (c *OperatorContainer) GetByName(name string) (*Operator, bool)
GetByName gets the operator by the name
func (*OperatorContainer) RegisterOperator ¶
func (c *OperatorContainer) RegisterOperator(op *Operator) error
RegisterOperator registers single operator
func (*OperatorContainer) RegisterOperators ¶
func (c *OperatorContainer) RegisterOperators(ops ...*Operator) error
RegisterOperators registers multiple operators