Add filter support for conjunctions (and), disjunctions (or), and negations (not)
Hopefully this is welcome! I am really impressed with what you are doing here, I started on a little prototype for a filtering system myself, but am nowhere as far along as this.
I want to suggest a feature and a data structure for adding some really cool functionality to filters.
Problem
The current approach for filters uses conjunctions by default, but it is often useful to combine conjunctions and disjunctions together.
Solution
Add support for conjunctions (and), and disjunctions (or).
This can be supported by recursively nesting query filters via "value":
Example conjunction with a disjunction:
filters: [
%{
"filter" => "and",
"value" => [
%{
"column" => "year",
"filter" => "equal",
"value" => 2010
},
{
"filter" => "or",
"value" => [
%{
"column" => "country",
"filter" => "equal",
"value" => "Angola"
},
%{
"column" => "country",
"filter" => "equal",
"value" => "Algeria"
}
]
}
]
}
]
With this you can combine and nest conjunctions, and disjunctions as needed. It also works well for building a UI with nested objects.
Negations I also wanted to suggest supporting negations directly for any given filter operator, e.g
%{
"filter" => "not equal",
}
becomes
%{
"filter" => "equal",
"negate" => true,
}
Negations then become a really simple toggle for any given filter. In your code you then can define a single operation direction, and the inverse is just a negation.
P.S. You can see an example of how this might work in this repo. I'm a novice at elixir, but I think this is illustrative of the idea.