Skip to content

Feature Request: Additional Filters #45

@cpursley

Description

@cpursley

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions