simple_repo v1.2.1 SimpleRepo.Query

SimpleRepo.Query provides a possibility to create scoped queries for Ecto:

SimpleRepo.Query.scoped(scopes)

Here scopes is a keyword list offering different possibilities to query against a database:

[

{key, nil}, # => "where key is nil"

{key, value}, # => where key is equal to value

{key, value_list}, # => where key is included in value_list

{key, {:like, pattern}}, # => where key matches pattern

{key, {:not, nil}}, # => "where key is not nil"

{key, {:not, value}}, # => where key is not equal to value

{key, {:not, value_list}}, # => where key is not included in value_list

{key, {:not_like, pattern}}, # => where key does not match pattern

{key, {:<, value}}, # => where key less than value

{key, {:<=, value}}, # => where key less than or equal value

{key, {:>, value}}, # => where key greater than value

{key, {:>=, value}}, # => where key greater than or equal to value

]

Example:

User |> Query.scoped([last_name: "Smith", age: {:>=, 21}]) |> Repo.all

Link to this section Summary

Link to this section Functions

Link to this function

ordered(queriable, order_list)

Link to this function

scoped(queriable, scopes)