ExOperation v0.3.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
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 ofEcto.Repo.preload/3
. Doesn’t preload any associations by default.:optional
– when enabled doesn’t return error butnil
if:id_path
is missing in the given params. Defaults tofalse
.:skip_missing
– when enabled doesn’t return error butnil
if the entity is missing in the database. Defaults tofalse
.:context_getter
– an optional function that gets the context and returns{:ok, schema}
,:not_found
, or{:error, reason}
. If:not_found
is returned then it tries to find the schema in the database as usual.
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 previous
steps and values are their return values.
It must return either {:ok, result}
or {:error, reason}
tuple.
Embeds another operation into the current one.
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.
Options
:id
– unique term to identify the suboperation (optional).:context
– override context (optional). It can be a map or a function that gets current transaction map and returns a context map to pass into the suboperation.