lrstanley/entrest

feat: support filter grouping for advanced searching

Closed this issue · 0 comments

Allows multiple fields under the same type to be logically OR'd, while still supporting AND operations for all other filter parameters.

Given the following schema:

User:
  username: string (entrest.WithFilterGroup("search"))
  display_name: string (entrest.WithFilterGroup("search"))
  email: string (entrest.WithFilterGroup("search"))
  type: enum (USER, ADMIN, BOT)

You could do: /users?type.eq=USER&search.ihas="John", which would do the following pseudocode behind the scenes:

and(type.eq==USER, or(username.ihas=="John", display_name.ihas=="John", email.ihas=="John"))

Some additional requirements:

  • All grouped fields must be of the same base type.
  • Only filter predicates which ALL grouped fields have will be included in the final grouped filter options.
    • TODO: should we instead move this to the schema, and pass in the names of the fields?