ExOperation v0.1.0 ExOperation.DSL View Source
Functions that help defining operations.
Link to this section Summary
Functions
Schedules a callback
function to run after successful database transaction commit
A conveniece step for fetching entities from the database.
It wraps Ecto.Repo.get/2
under the hood
Adds an arbitrary step to the operation pipeline
Embeds another operation into the current one. Step names must not interfere
Link to this section Types
Link to this section Functions
Schedules a callback
function to run after successful database transaction commit.
The callback
receives the map of results of each step. The return value is ignored.
A conveniece step for fetching entities from the database.
It wraps Ecto.Repo.get/2
under the hood.
Options
:schema
– an Ecto.Schema module name to find for. This options is required.
:id_path
– param name or path list for deeply nested id key. Defaults to [:id]
.
:preloads
– a list of association preloading in the format of Ecto.Repo.preload/3
.
Doesn’t preload any associations by default.
:optional
– when enabled doesn’t return error but nil
if :id_path
is missing
in the given params. Defaults to false
.
:skip_missing
– when enabled doesn’t return error but nil
if the entity is missing
in the database. Defaults to false
.
Adds an arbitrary step to the operation pipeline.
callback
is a function that accepts a map of changes so far where keys are names of preivous
steps and values are their return values.
It must return either {:ok, result}
or {:error, reason}
tuple.
Embeds another operation into the current one. Step names must not interfere.
module
is the suboperation module.
params_or_fun
can be either a map or a callback function that gets changes so far
and returns a map. The map will be passed to the suboperation.
Context is passed without changes.