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 they 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 examples
from(City, select: c)
## Expressions examples
City |> select([c], c)
def paginate(query, page, size) do
offset: ^((page-1) * size)
The example above does not use `in` because none of `limit` and `offset`
requires such. However, extending a query with where expression would
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.
In case the given query has more than one `from` expression, each of them
must be given 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` must be named as you find more convenient
as they have no importance in the query sent to the database.
- Describe the parameter "kw".
- Describe the parameter "expr".