Skip to content

how to filter on all filterable fields #394

Closed Answered by kuatroka
kuatroka asked this question in Q&A

You must be logged in to vote

All is sorted now. I had to use compound_fields and also add the new virtual field that would combine both fields to the list of filterable:

@derive {
    Flop.Schema,
    filterable: [:country_code, :country_name, :search],
    sortable: [:country_id, :country_code, :country_name],
    default_limit: 10,
    adapter_opts: [
      compound_fields: [
        search: [:country_code, :country_name]
      ]
    ]
  }

and I had to change my convoluted query into a simpler Flop's query.

def list_countries2(params) do
    Flop.validate_and_run(
      Country,
      params,
      for: Country,
      default_limit: 5,
      default_order: [asc: :country_name]
    )
  end

Replies: 1 comment

You must be logged in to vote
0 replies
Answer selected by kuatroka
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant