Chronicle. Multi
(chronicle v0.1.1)
Copy Markdown
Audited operations for an ordinary Ecto.Multi.
Each helper adds the requested Ecto operation followed by an audit step in the same repository transaction. No wrapper struct or special transaction function is involved.
What goes in is an Ecto.Multi and what comes out is an Ecto.Multi, so
everything that already works on one keeps working: inspecting the
operations, appending to it, merging it, running it with the repo's own
transaction/2. A wrapper type would have to re-expose all of that, would
drift from Ecto.Multi as it gained features, and would buy nothing — the
audit step is just another named operation, which is what Ecto.Multi is
already for.
Summary
Functions
Adds one audit step. Audit failures abort the surrounding transaction.
Adds an arbitrary audit fact built from preceding Multi results.
Functions
@spec audit( Ecto.Multi.t(), Ecto.Multi.name(), (map() -> Chronicle.Event.t()), keyword() ) :: Ecto.Multi.t()
Adds one audit step. Audit failures abort the surrounding transaction.
@spec delete( Ecto.Multi.t(), Ecto.Multi.name(), Ecto.Changeset.t() | struct(), keyword() ) :: Ecto.Multi.t()
@spec insert(Ecto.Multi.t(), Ecto.Multi.name(), Ecto.Changeset.t(), keyword()) :: Ecto.Multi.t()
@spec record( Ecto.Multi.t(), Ecto.Multi.name(), (map() -> Chronicle.Event.t() | String.t() | tuple()), keyword() ) :: Ecto.Multi.t()
Adds an arbitrary audit fact built from preceding Multi results.
The builder may return an Chronicle.Event, an event type, {type, data},
or {type, data, options}.
@spec update(Ecto.Multi.t(), Ecto.Multi.name(), Ecto.Changeset.t(), keyword()) :: Ecto.Multi.t()