Filtering
Colton J. Provias edited this page Oct 2, 2015
·
1 revision
The proposal is to have two different filtering systems built-in that can run together simultaneously. First, and probably easiest to implement, is the simple filtering system:
In simple filtering, we assume all arguments are chained via AND operators. To perform filtering on a field, you put the field name in brackets and append the operation to the end. For example:
filter[author.eq]=users.d77f0ffe-4e92-446c-884a-14ad03c0b77f
filter[author.ne]=users.d77f0ffe-4e92-446c-884a-14ad03c0b77f
filter[score.gt]=5
filter[score.ge]=5
filter[score.lt]=5
filter[score.le]=5
filter[title.like]=%40Hello%40
filter[title.ilike]=%40Hello%40
filter[author.in]=users.d77f0ffe-4e92-446c-884a-14ad03c0b77f%2Cusers.5d1b789e-5a59-4f3e-b03e-3d675d0cd17a
filter[author.notin]=users.d77f0ffe-4e92-446c-884a-14ad03c0b77f%2Cusers.5d1b789e-5a59-4f3e-b03e-3d675d0cd17a
filter[author.is]=null
filter[author.isnt]=null
filter[title.starts]=Hello
filter[title.ends]=World
filter[title.contains]=ello
filter[comments.contains]=comments.7d3ef70f-6a0c-4cc7-8158-5e10c3e52c41
And of course across relationships, some will work:
filter[author.email.eq]=myemail@example.com
Full filtering allows you to code your filters more naturally. Let's say you want all posts with scores between 5 and 10 that are published:
(5 < score <= 10) and is_published
This is then urlencoded and provided as a filter on the request:
?filter=(5%20%3C%20score%20%3C%3D%2010)%20and%20is_published
This way, you can be more expressive if you desire with your filters.