ash_double_entry/lib/account/preparations/lock_for_update.ex

13 lines
340 B
Elixir
Raw Normal View History

defmodule AshDoubleEntry.Account.Preparations.LockForUpdate do
2023-08-19 16:17:07 +12:00
@moduledoc "Locks the results of the query for update"
use Ash.Resource.Preparation
def prepare(query, _, _) do
if Ash.DataLayer.data_layer_can?(query.resource, {:lock, :for_update}) do
Ash.Query.lock(query, :for_update)
else
query
end
end
end