Documentation ¶
Index ¶
- func RegisterMultipleOperators(operators ...*Operator) error
- func RegisterOperator(o *Operator) error
- type FilterField
- func NewFilter(field *mapping.StructField, op *Operator, values ...interface{}) (f *FilterField)
- func NewRelationshipFilter(relation *mapping.StructField, relFilters ...*FilterField) *FilterField
- func NewStringFilter(c *controller.Controller, filter string, schemaName string, ...) (*FilterField, error)
- type Operator
- type OperatorContainer
- type OperatorValuePair
- type QueryValuer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterMultipleOperators ¶
RegisterMultipleOperators registers multiple operators at once
func RegisterOperator ¶
RegisterOperator registers the operator in the provided container
Types ¶
type FilterField ¶
type FilterField filters.FilterField
FilterField is a struct that keeps information about given query filters It is based on the mapping.StructField.
func NewFilter ¶
func NewFilter( field *mapping.StructField, op *Operator, values ...interface{}, ) (f *FilterField)
NewFilter creates new filterfield for given field, operator and values
func NewRelationshipFilter ¶
func NewRelationshipFilter( relation *mapping.StructField, relFilters ...*FilterField, ) *FilterField
NewRelationshipFilter creates new relationship filter for the 'relation' StructField It adds all the nested relation subfilters 'relFilters'
func NewStringFilter ¶
func NewStringFilter(c *controller.Controller, filter string, schemaName string, values ...interface{}) (*FilterField, error)
NewStringFilter creates the filter field based on the provided filter, schemaName and values The filter should not contain the values. If the 'schemaName' is not provided the defaultSchema for given controller would be taken. Example:
- 'fitler': "filter[collection][fieldName][operator]"
- 'schema': "schemaName"
- 'values': 5, 13
func (*FilterField) FormatQuery ¶
func (f *FilterField) FormatQuery(q ...url.Values) url.Values
FormatQuery formats the filter field into url.Value format If the 'q' optional parameter is set, then the function would add the values into the provided argument url.Values. Otherwise it creates new url.Values. Returns updated (new) url.Values
func (*FilterField) NestedFilters ¶
func (f *FilterField) NestedFilters() []*FilterField
NestedFilters returns the nested filters for given filter fields Nested filters are the filters used for relationship filters
func (*FilterField) StructField ¶
func (f *FilterField) StructField() *mapping.StructField
StructField returns the structfield related with the filter field
func (*FilterField) Values ¶
func (f *FilterField) Values() (values []*OperatorValuePair)
Values returns OperatorValuesPair for given filterField
type Operator ¶
Operator is a query filter operator. It is an alias to a pointer so it can be comparable with equal sign
var ( // OpEqual is the standard filter operator OpEqual *Operator = (*Operator)(filters.OpEqual) // OpIn is the standard filter operator OpIn *Operator = (*Operator)(filters.OpIn) // OpNotEqual is the standard filter operator OpNotEqual *Operator = (*Operator)(filters.OpNotEqual) // OpNotIn is the standard filter operator OpNotIn *Operator = (*Operator)(filters.OpNotIn) // OpGreaterThan is the standard filter operator OpGreaterThan *Operator = (*Operator)(filters.OpGreaterThan) // OpGreaterEqual is the standard filter operator OpGreaterEqual *Operator = (*Operator)(filters.OpGreaterEqual) // OpLessThan is the standard filter operator OpLessThan *Operator = (*Operator)(filters.OpLessThan) // OpLessEqual is the standard filter operator OpLessEqual *Operator = (*Operator)(filters.OpLessEqual) // OpContains is the standard filter operator OpContains *Operator = (*Operator)(filters.OpContains) // OpStartsWith is the standard filter operator OpStartsWith *Operator = (*Operator)(filters.OpStartsWith) // OpEndsWith is the standard filter operator OpEndsWith *Operator = (*Operator)(filters.OpEndsWith) // OpIsNull is the standard filter operator OpIsNull *Operator = (*Operator)(filters.OpIsNull) // OpNotNull is the standard filter operator OpNotNull *Operator = (*Operator)(filters.OpNotNull) // OpExists is the standard filter operator OpExists *Operator = (*Operator)(filters.OpExists) // OpNotExists is the standard filter operator OpNotExists *Operator = (*Operator)(filters.OpNotExists) )
Standard filter operators
func NewOperator ¶
NewOperator creates new operator with the 'name' and 'queryRaw' provided in the arguments
func (*Operator) IsStandard ¶
IsStandard defines if the operator is a standard filter operator
type OperatorContainer ¶
type OperatorContainer struct {
// contains filtered or unexported fields
}
OperatorContainer is a container for the provided operators. It allows registering new and getting already registered operators.
func NewContainer ¶
func NewContainer() *OperatorContainer
NewContainer creates new operator container
type OperatorValuePair ¶
type OperatorValuePair filters.OpValuePair
OperatorValuePair is a struct that holds the Operator information with the
func (*OperatorValuePair) Operator ¶
func (o *OperatorValuePair) Operator() *Operator
Operator returns the operator for given pair
func (*OperatorValuePair) SetOperator ¶
func (o *OperatorValuePair) SetOperator(op *Operator)
SetOperator sets the operator
type QueryValuer ¶
type QueryValuer interface {
QueryValue(sField *mapping.StructField) string
}
QueryValuer is the interface that allows parsing the structures into golang filters string values