How to perform a bulk destroy in a destroy action

destroy :destroy do
      argument :ids, {:array, :integer}, allow_nil?: true

      change relate_actor(:user)

      run fn input, context ->
        ids = input.arguments.ids
        IO.inspect(ids)
      end
    end

I want to get the ids values and delete them in bulk.

But I realised that run is not in the destory.

Should I use menual or is there a better way?

I assume this thread: I don't know why Ash.bulk_destory!/2 undefined bulk_destory - #3 by zachdaniel is you moving forward on the topic, but I will post a short answer here for others who end up here :slight_smile:

An individual destroy action is always modeled as just that, an individual destroy. We use Ash.bulk_destroy/4 to run a destroy action in bulk. If you want an action on the resource responsible for this, you would use a generic action.

1 Like