View on GitHub
A lock query expression.
Provides support for row-level pessimistic locking using
`SELECT ... FOR UPDATE` or other, database-specific, locking clauses.
`expr` can be any expression but has to evaluate to a boolean value or to a
string and it can't include any fields.
If `lock` is used more than once, the last one used takes precedence.
Ecto also supports [optimistic
locking](http://en.wikipedia.org/wiki/Optimistic_concurrency_control) but not
through queries. For more information on optimistic locking, have a look at
the `Ecto.Model.OptimisticLock` module.
## Keywords examples
from(u in User, where: u.id == ^current_user, lock: "FOR SHARE NOWAIT")
## Expressions examples
User |> where(u.id == ^current_user) |> lock("FOR SHARE NOWAIT")