You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After considerable trial and error, these are the correct instructions for this to work:
// patient_filters.ex
defmodule PatientFilters do
use Filterable.DSL
use Filterable.Ecto.Helpers
use Filterable
import Ecto.Query
field(:name)
field(:gender)
paginateable(per_page: 10)
filterable do
@options param: :name
filter name(query, value) do
query |> where([u], ilike(u.name, ^"%#{value}%"))
end
@options param: :gender
filter gender(query, value) do
query |> where(gender: ^value)
end
end
end
And in controller:
def index(conn, _params) do
with {:ok, query, filter_values} <- PatientFilters.apply_filters(Patient, _params),
patients <- Repo.all(query),
do: render(conn, "index.json", patients: patients, meta: filter_values)
end
The text was updated successfully, but these errors were encountered:
After considerable trial and error, these are the correct instructions for this to work:
And in controller:
The text was updated successfully, but these errors were encountered: