AshEvents.DestroyActionWrapper (ash_events v0.7.0)

Copy Markdown View Source

Wrapper for destroy actions that enables event tracking.

This module handles both hard and soft deletes. Soft deletes (actions with soft?: true) are implemented by Ash as updates under the hood, so this module implements both destroy/3 for hard deletes and update/3 for soft deletes.

Summary

Functions

Handles bulk soft destroy actions.

Handles hard destroy actions.

Handles soft destroy actions (where soft?: true).

Functions

bulk_update(changesets, module_opts, bulk_ctx)

Handles bulk soft destroy actions.

When Ash converts a bulk soft-delete destroy into a bulk update, the changeset context key is :bulk_destroy but the bulk update pipeline expects :bulk_update. Implementing bulk_update/3 allows us to tag results with their changesets directly, bypassing the context key mismatch.

destroy(changeset, module_opts, ctx)

Handles hard destroy actions.

update(changeset, module_opts, ctx)

Handles soft destroy actions (where soft?: true).

Ash implements soft deletes as updates, so it calls update/3 on the manual module.