View Source Bonfire.Common.Repo.Filter (Bonfire v0.9.10-classic-beta.169)
query_filter
brings convenience and shortens the boilterplate of ecto queries
Common filters available include:
preload
- Preloads fields onto the query resultsstart_date
- Query for items inserted after this dateend_date
- Query for items inserted before this datebefore
- Get items with IDs before this valueafter
- Get items with IDs after this valueids
- Get items with a list of idsfirst
- Gets the first n itemslast
- Gets the last n itemslimit
- Gets the first n itemsoffset
- Offsets limit by n itemssearch
- Warning: This requires schemas using this to have a&by_search(query, val)
function
You are also able to filter on any natural field of a model, as well as use
- gte/gt
- lte/lt
- like/ilike
- is_nil/not(is_nil)
query_filter(User, %{name: %{ilike: "steve"}})
query_filter(User, %{name: %{ilike: "steve"}}, :last_name, :asc)
query_filter(User, %{name: %{age: %{gte: 18, lte: 30}}})
query_filter(User, %{name: %{is_banned: %{!=: nil}}})
query_filter(User, %{name: %{is_banned: %{==: nil}}})
my_query = query_filter(User, %{name: "Billy"})
query_filter(my_query, %{last_name: "Joe"})
Summary
Functions
Link to this function