View on GitHub
Creates a query.
It can either be a keyword query or a query expression. If it is a
keyword query the first argument should be an `in` expression and
the second argument a keyword query where the keys are expression
types and the values are expressions.
If it is a query expression the first argument is the original query
and the second argument the expression.
## Keywords example
from(City, select: c)
## Expressions example
City |> select([c], c)
def paginate(query, page, size) do
offset: ^((page-1) * size)
The example above does not use `in` because `limit` and `offset`
do not require such. However, extending a query with a where expression would
require the use of `in`:
def published(query) do
from p in query, where: p.published_at != nil
Notice we have created a `p` variable to represent each item in the query.
When the given query has more than one `from` expression, a variable
must be given for each in the order they were bound:
def published_multi(query) do
from [p,o] in query,
where: p.published_at != nil and o.published_at != nil
Note the variables `p` and `o` can be named whatever you like
as they have no importance in the query sent to the database.
- Describe the parameter "kw".
- Describe the parameter "expr".