Bonfire.Ecto
contains Ecto
transactional support as acts for Bonfire.Epics
Bonfire.Ecto
is designed to facilitate complex Ecto transaction handling within an Elixir application that uses Bonfire.Epics
to execute a sequence of operations (or Acts
). These modules provide a structured way to manage database transactions as a series of acts and managing them within an Epic
, offering flexibility and control over database interactions, ensuring that transactions are executed efficiently.
Bonfire.Ecto.Acts.Begin
Epic
.Bonfire.Ecto.Acts.Work
Bonfire.Ecto.Acts.Work.add/2
function and executed if there are no errors in the Epic
or changesets.Bonfire.Ecto.Acts.Commit
Bonfire.Ecto.Acts.Begin
to identify when to commit the transaction.Ensure that you have Ecto
and Bonfire.Epics
installed and configured in your application, and then install this linrary.
Bonfire.Ecto.Acts.Begin
#Refer to Bonfire.Epics
docs to define some Act
s and Epic
s: https://github.com/bonfire-networks/bonfire_epics
Queue operations by calling the Bonfire.Ecto.Acts.Work.add/2
function, providing the epic and a key representing the changeset to be processed.
epic = Bonfire.Ecto.Acts.Work.add(epic, :some_changeset)
Bonfire.Ecto
Acts to your Epic # # First come the Acts that prepare the changeset and call `Bonfire.Ecto.Acts.Work.add/2` to queue it
# Open a Postgres transaction and actually do the insertions in DB
Bonfire.Ecto.Acts.Begin,
# Run our inserts
Bonfire.Ecto.Acts.Work,
Bonfire.Ecto.Acts.Commit,
# Then can come some Acts that process the result of the transaction