def build_query(%Queries{options: opts}) when is_list(opts) do
base_query =
from r in Record,
order_by: r.submitted_time
Enum.reduce(opts, base_query, fn prop, q ->
process_filter(q, prop)
end)
end
def process_filter(query, {_key, _value} = w) do
from x in query,
where: ^[w]
end
I’m not sure if the above will work… but the key here, is that I’m trying to pass the key into the query builder such that the function doesn’t need to be aware of the schema, so I have to be bindingless.