new filter
General Concepts
Some resources support paging, sorting and filtering using common syntax.
Paging
Paging is controller via following parameters:
offset
default value: 0
accepted values: integer >= 0
limit
default value: 10
accepted values: integer > 0
Example: ?offset=4&limit=3 returns items from 5 to 7.
Total number of items (regardless set limit) is returned in X-Total-Count header.
Sorting
Order of returned data may be controlled by passing parameter sort in the following format: [+|-]attribute1[|[+|-]attribute2]... Items are sorted by id by default.
Attributes are separated with | sign. Each attribute may be prefixed by + or - sign, denoting ascending (default if ommited) or descending order.
Example: ?sort=name|-category
Filtering
Following operators are defined:
Is equal
representation: eq
valid for: boolean, integer, double, datetime, text
Not equal
representation: ne
valid for: boolean, integer, double, datetime, text
Greater than
representation: gt
valid for: integer, double, datetime
Greater or equal
representation: ge
valid for: integer, double, datetime
Less than
representation: lt
valid for: integer, double, datetime
Less or equal
representation: le
valid for: integer, double, datetime
In range
representation: between
valid for: integer, double, datetime
Contains
representation: contains
valid for: text
Starts with
representation: startswith
valid for: text
Ends with
representation: endswith
valid for: text
A filter phrase consists of an attribute name, an operator and one or more values separated with ::. Phrases are separated with |. Phrases applied to the same attribute are combined using the operator or, distinct attributes with and.
Example: ?filter=name::contains::Bonus|category::eq::savings|category::eq::mortgages|price::between::50.0::300.0|inserted::gt::2015-01-13T02:13:40Z
is translated into the following expression
name LIKE '%Bonus%' AND (category = 'savings' OR category = 'mortgages') AND price >= 50.0 AND price <= 300.0 AND inserted > '2015-01-13T02:13:40Z'
Edited by Tomáš Benedikt