Skuld.Effects.Port.Repo.Ecto (skuld v0.23.0)

View Source

Macro for generating a Port.Repo.Behaviour implementation that delegates to a specific Ecto Repo module.

Each operation in the Port.Repo contract is implemented by calling the corresponding function on the configured Repo module with the same arguments.

Usage

defmodule MyApp.Repo.Port do
  use Skuld.Effects.Port.Repo.Ecto, repo: MyApp.Repo
end

This generates a module satisfying Skuld.Effects.Port.Repo.Behaviour with functions like:

def insert(changeset), do: MyApp.Repo.insert(changeset)
def update(changeset), do: MyApp.Repo.update(changeset)
# ... etc.

Handler Installation

alias Skuld.Effects.Port

comp
|> Port.with_handler(%{Port.Repo => MyApp.Repo.Port})
|> Comp.run!()