Skuld.Effects.Port.Repo (skuld v0.23.0)
View SourceEffectful dispatch facade for Skuld.Effects.Port.Repo.Effectful.
Provides typed public functions returning computation(return_type)
values that dispatch to the configured implementation via the Port
effect. Also provides bang variants (unwrap or throw) and __key__
helpers for test stub matching.
Summary
Functions
Build a test stub key for the exists? port operation.
Build a test stub key for the get_by! port operation.
Build a test stub key for the aggregate port operation.
Calculate an aggregate over the given field.
Fetch all records matching a queryable.
Delete a record.
Port operation: delete!/1
Delete all records matching a queryable.
Check whether any record matching the queryable exists.
Fetch a single record by primary key. Returns nil if not found.
Fetch a single record by primary key, or dispatch Throw if not found.
Fetch a single record by the given clauses. Returns nil if not found.
Fetch a single record by the given clauses, or dispatch Throw if not found.
Insert a new record from a changeset.
Port operation: insert!/1
Insert all entries into a schema or source at once.
Fetch a single result from a query. Returns nil if no result.
Fetch a single result from a query, or dispatch Throw if no result.
Update an existing record from a changeset.
Port operation: update!/1
Update all records matching a queryable.
Functions
Build a test stub key for the exists? port operation.
Build a test stub key for the get_by! port operation.
Build a test stub key for the aggregate port operation.
@spec aggregate(Ecto.Queryable.t(), atom(), atom()) :: Skuld.Comp.Types.computation(term())
Calculate an aggregate over the given field.
@spec all(Ecto.Queryable.t()) :: Skuld.Comp.Types.computation([struct()])
Fetch all records matching a queryable.
@spec delete(struct()) :: Skuld.Comp.Types.computation({:ok, struct()} | {:error, Ecto.Changeset.t()})
Delete a record.
@spec delete!(struct()) :: Skuld.Comp.Types.computation(struct())
Port operation: delete!/1
Like delete/1 but unwraps {:ok, value} or dispatches Throw on error.
@spec delete_all( Ecto.Queryable.t(), keyword() ) :: Skuld.Comp.Types.computation({non_neg_integer(), nil | list()})
Delete all records matching a queryable.
@spec exists?(Ecto.Queryable.t()) :: Skuld.Comp.Types.computation(boolean())
Check whether any record matching the queryable exists.
@spec get(Ecto.Queryable.t(), term()) :: Skuld.Comp.Types.computation(struct() | nil)
Fetch a single record by primary key. Returns nil if not found.
@spec get!(Ecto.Queryable.t(), term()) :: Skuld.Comp.Types.computation(struct())
Fetch a single record by primary key, or dispatch Throw if not found.
Mirrors Ecto.Repo.get!/2 — in the effectful context this dispatches
Throw with {:not_found, queryable, id} instead of raising.
@spec get_by(Ecto.Queryable.t(), keyword() | map()) :: Skuld.Comp.Types.computation(struct() | nil)
Fetch a single record by the given clauses. Returns nil if not found.
@spec get_by!(Ecto.Queryable.t(), keyword() | map()) :: Skuld.Comp.Types.computation(struct())
Fetch a single record by the given clauses, or dispatch Throw if not found.
Mirrors Ecto.Repo.get_by!/2.
@spec insert(Ecto.Changeset.t()) :: Skuld.Comp.Types.computation({:ok, struct()} | {:error, Ecto.Changeset.t()})
Insert a new record from a changeset.
@spec insert!(Ecto.Changeset.t()) :: Skuld.Comp.Types.computation(struct())
Port operation: insert!/1
Like insert/1 but unwraps {:ok, value} or dispatches Throw on error.
@spec insert_all( Ecto.Queryable.t() | binary(), [map() | keyword()], keyword() ) :: Skuld.Comp.Types.computation({non_neg_integer(), nil | list()})
Insert all entries into a schema or source at once.
@spec one(Ecto.Queryable.t()) :: Skuld.Comp.Types.computation(struct() | nil)
Fetch a single result from a query. Returns nil if no result.
@spec one!(Ecto.Queryable.t()) :: Skuld.Comp.Types.computation(struct())
Fetch a single result from a query, or dispatch Throw if no result.
Mirrors Ecto.Repo.one!/1.
@spec update(Ecto.Changeset.t()) :: Skuld.Comp.Types.computation({:ok, struct()} | {:error, Ecto.Changeset.t()})
Update an existing record from a changeset.
@spec update!(Ecto.Changeset.t()) :: Skuld.Comp.Types.computation(struct())
Port operation: update!/1
Like update/1 but unwraps {:ok, value} or dispatches Throw on error.
@spec update_all(Ecto.Queryable.t(), keyword(), keyword()) :: Skuld.Comp.Types.computation({non_neg_integer(), nil | list()})
Update all records matching a queryable.