Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Additional Filters #45

Open
cpursley opened this issue Jul 6, 2021 · 0 comments
Open

Feature Request: Additional Filters #45

cpursley opened this issue Jul 6, 2021 · 0 comments

Comments

@cpursley
Copy link

cpursley commented Jul 6, 2021

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

https://hasura.io/docs/latest/graphql/core/databases/postgres/queries/query-filters.html#text-search-or-pattern-matching-operators-like-similar-etc

  • 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).

@cpursley cpursley changed the title Feature Request: Addional Filters Feature Request: Additional Filters Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant