ash_double_entry/lib/account/preparations/lock_for_update.ex
2023-09-26 09:46:07 -04:00

13 lines
348 B
Elixir

defmodule AshDoubleEntry.Account.Preparations.LockForUpdate do
# Locks the results of the query for update
@moduledoc false
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