Documentation
¶
Index ¶
- Constants
- type Direction
- type Filter
- type Operator
- type Option
- func WithFilter(filter *Filter) Option
- func WithFilterArgs(fieldName string, op Operator, operand interface{}) Option
- func WithFilters(filters ...*Filter) Option
- func WithOrder(order *Order) Option
- func WithOrderArgs(fieldName string, dir Direction) Option
- func WithOrders(orders ...*Order) Option
- func WithPage(page *Page) Option
- func WithPageArgs(startIndex, capacity int) Option
- type Order
- type Page
- type Query
Constants ¶
const ( OpNone = "" OpEqual = "==" OpNotEqual = "!=" OpGreaterThan = ">" OpGreaterThanOrEqual = ">=" OpLessThan = "<" OpLessThanOrEqual = "<=" OpIn = "IN" )
Enumeration of possible operators.
const ( DirNone = "" DirAscending = "asc" DirDescending = "desc" )
Enumeration of possible order directions.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Operator ¶
type Operator string
Operator defines a logical operator, eg. equal, greater than, or in.
type Option ¶
type Option func(q *Query)
Option defines a way to pass build options to a new query.
func WithFilter ¶
WithFilter adds the specified filter to the query.
func WithFilterArgs ¶
WithFilterArgs builds a new Filter instance composed of the specified fieldName, op, and operand arguments, and adds it to the query.
func WithFilters ¶
WithFilters adds the specified filters to the query.
func WithOrderArgs ¶
WithOrderArgs builds a new Order instance composed of the specified fieldName and dir arguments, and adds it to the query.
func WithOrders ¶
WithOrders adds the specified orders to the query.
func WithPageArgs ¶
WithPageArgs builds a new Page instance composed of the specified startIndex and capacity arguments, and adds it to the query.
type Query ¶
Query defines a group of modifiers that can change the way resources are retrieved and displayed.
func NewQuery ¶
NewQuery creates a new query. Options can be specified to provide initial values to the query.
The following example shows how different types of options can be used:
NewQuery( WithFilters( NewFilter("FieldName1", OpEqual, "operand1"), NewFilter("FieldName2", OpNotEqual, "operand2"), ), WithOrder(NewOrder("FieldName1", DirAscending)), WithOrder(NewOrder("FieldName2", DirDescending)), WithPageArgs(10, 20), )
func (*Query) AddFilters ¶
AddFilters adds the specified filters to the query.