Skip to content

Let's add choices!

Compare
Choose a tag to compare
@ricktap ricktap released this 12 Aug 10:49
· 1 commit to master since this release

Added a second Filter Implementation to point out how easy it is to create your own filters. Unfortunately this needs to be a mandatory option for me to support, as the json api specification is not clear about how the filter request parameter should look like. As of right now, the Qriteria Package supports a nested string filter and an array field filter or anything you can think of yourself:

NestedString:

?filter=name:=:Bob,(age:<:25|age:>:50)

This is the filter to go with, if you need a lot of control over your queries. The above would translate to:

WHERE name = 'Bob' AND (age < 25 OR age > 50)

In the example the , means AND, the | means or. Everything between parentheses will be grouped. The operations = and < will be expanded by keywords like eq and lt in a future version. The new syntax would then look like:

?filter=name:eq:Bob,(age:lt:25|age:gt:50)

ArrayField

?filter[name]=Bob&filter[age]=25

This Version does not support operations like less than or like, but only does plain old equals. There is also no support for grouping and telling the filters to perform an or. Since there is no or, there was no reason for me to include an option to have the same field twice. On multiple definition of filter[field], the last occurrence would take precedence over the others. The example would perform the following query:

WHERE name = 'Bob' and age = 25