Skuld.Effects.Port.Repo.Effectful behaviour (skuld v0.23.0)

View Source

Effectful behaviour for Skuld.Effects.Port.Repo.Contract.

Defines computation-returning callbacks for each Repo operation. Effectful implementations declare @behaviour Skuld.Effects.Port.Repo.Effectful.

Summary

Callbacks

aggregate(queryable, aggregate, field)

@callback aggregate(queryable :: Ecto.Queryable.t(), aggregate :: atom(), field :: atom()) ::
  Skuld.Comp.Types.computation(term())

all(queryable)

@callback all(queryable :: Ecto.Queryable.t()) :: Skuld.Comp.Types.computation([struct()])

delete(record)

@callback delete(record :: struct()) ::
  Skuld.Comp.Types.computation({:ok, struct()} | {:error, Ecto.Changeset.t()})

delete_all(queryable, opts)

@callback delete_all(queryable :: Ecto.Queryable.t(), opts :: keyword()) ::
  Skuld.Comp.Types.computation({non_neg_integer(), nil | list()})

exists?(queryable)

@callback exists?(queryable :: Ecto.Queryable.t()) ::
  Skuld.Comp.Types.computation(boolean())

get(queryable, id)

@callback get(queryable :: Ecto.Queryable.t(), id :: term()) ::
  Skuld.Comp.Types.computation(struct() | nil)

get!(queryable, id)

@callback get!(queryable :: Ecto.Queryable.t(), id :: term()) ::
  Skuld.Comp.Types.computation(struct())

get_by(queryable, clauses)

@callback get_by(queryable :: Ecto.Queryable.t(), clauses :: keyword() | map()) ::
  Skuld.Comp.Types.computation(struct() | nil)

get_by!(queryable, clauses)

@callback get_by!(queryable :: Ecto.Queryable.t(), clauses :: keyword() | map()) ::
  Skuld.Comp.Types.computation(struct())

insert(changeset)

@callback insert(changeset :: Ecto.Changeset.t()) ::
  Skuld.Comp.Types.computation({:ok, struct()} | {:error, Ecto.Changeset.t()})

insert_all(source, entries, opts)

@callback insert_all(
  source :: Ecto.Queryable.t() | binary(),
  entries :: [map() | keyword()],
  opts :: keyword()
) :: Skuld.Comp.Types.computation({non_neg_integer(), nil | list()})

one(queryable)

@callback one(queryable :: Ecto.Queryable.t()) ::
  Skuld.Comp.Types.computation(struct() | nil)

one!(queryable)

@callback one!(queryable :: Ecto.Queryable.t()) :: Skuld.Comp.Types.computation(struct())

update(changeset)

@callback update(changeset :: Ecto.Changeset.t()) ::
  Skuld.Comp.Types.computation({:ok, struct()} | {:error, Ecto.Changeset.t()})

update_all(queryable, updates, opts)

@callback update_all(
  queryable :: Ecto.Queryable.t(),
  updates :: keyword(),
  opts :: keyword()
) ::
  Skuld.Comp.Types.computation({non_neg_integer(), nil | list()})