-
Notifications
You must be signed in to change notification settings - Fork 11
Description
It would be useful to have more filters in addition to eq and in.
There's some ideas in this library: https://github.com/mathieuprog/query_builder/blob/master/lib/query/where.ex#L140
And from Hasura's where syntax: https://hasura.io/docs/latest/graphql/core/databases/postgres/queries/query-filters.html#the-where-argument
Suggestions
Comparison operators
- in (in) ~ as alternative option
- nin (not x in list)
- eq (==) ~ as alternative option
- neq (!=)
- gt (>)
- gte (>=)
- lt (<)
- lte (<=)
Usage:
Crudry.Query.filter(MySchema, %{id: 5, age: %{gte: 20, lte: 70}, name: %{neq: "John"}})
It would also be nice to have an or operator but I'm not sure what that syntax might look like.
Search operators
- like
- nlike
- ilike
- nilike
- similar
- nsimilar
- regex
- nregex
- iregex
- niregex
Usage:
Crudry.Query.filter(MySchema, %{name: %{like: "%John%"}})
And we could check instead of is_list or binary, check for map and it's operators.
If this sounds useful I'd be glad to work on this feature (and am interested in other's feedback & ideas).