Condition defining with operators other than equality
vincentvanbush opened this issue · comments
Michał Buszkiewicz commented
Prerequisite for #2.
We would like to be able to define queries like this:
def can(%{role: :visitor} = role) do
grant(role)
|> read(Record, approved: true, rating: {:>=, 5))
|> read(Record, public: true)
end
Because we want Ecto query creation in #2, we would like to use operators that can be transformed to both plain-Elixir usage and transformation to Ecto queries:
- Comparison operators: ==, !=, <=, >=, <, > aliased to
:eq
,:neq
,:gt
,:gte
,:lt
,:lte
- Search functions: like/2 and ilike/2, mapped to appropriate regexps (expressions will have to be somehow translated from e.g.
"%FOO"
to/.*FOO/
- Regexp matching via SQL
~
(:~
,:match
) - for this purpose Ecto fragments will have to be used - Null check functions: is_nil/1