Ecto.Query.lock

You're seeing just the macro lock, go back to Ecto.Query module for more information.
Link to this macro

lock(query, binding \\ [], expr)

View Source (macro)

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 but not through queries. For more information on optimistic locking, have a look at the Ecto.Changeset.optimistic_lock/3 function.

Keywords example

from(u in User, where: u.id == ^current_user, lock: "FOR SHARE NOWAIT")

Expressions example

User |> where(u.id == ^current_user) |> lock("FOR SHARE NOWAIT")