Is there a way to override the update in resource?

like this

update :update do
      manual fn changeset, _ ->
       
      end
    end
1 Like

That is exactly the way to do it. Is this a question or are you sharing the answer?

It’s a question, but what do I put inside the function to update? Because I didn’t find any examples.

I tried: changeset |> Ash.update()

But stays in the loop

A manual update action means “I’m going to handle the actual update logic”. That could involve calling a different update action, or calling something like Repo.insert manually. But yes if you call the same action it will loop forever (like standard recursion).

In what way do you want to override the update behavior?

I found the solution, I managed to understand how it works

update :update do
      change fn changeset, _ ->
        Ash.Changeset.after_action(changeset, fn changeset, result ->
do_something(result)
 {:ok, result} end)
      end
    end
1 Like