ash_double_entry/lib/account/preparations/lock_for_update.ex
2023-08-19 00:17:07 -04:00

12 lines
340 B
Elixir

defmodule AshDoubleEntry.Account.Preparations.LockForUpdate do
@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