Skuld.Repo (skuld v0.27.2)

View Source

Effectful dispatch facade for Skuld.Repo.Effectful.

Provides typed public functions returning computation(return_type) values that dispatch to the configured implementation via the Port effect. Also provides __key__ helpers for test stub matching.

Summary

Functions

Build a test stub key for the reload! port operation.

Build a test stub key for the load port operation.

Build a test stub key for the preload port operation.

Build a test stub key for the aggregate port operation.

Calculate an aggregate over the given field.

Calculate an aggregate over the given field with options.

Fetch all records matching a queryable.

Fetch all records matching a queryable with options.

Fetch all records matching the given clauses.

Fetch all records matching the given clauses with options.

Delete a record or changeset.

Delete a record or changeset with options.

Delete a record or changeset, raising on failure. Mirrors Ecto.Repo.delete!/2.

Delete a record or changeset with options, raising on failure.

Delete all records matching a queryable.

Check whether any record matching the queryable exists.

Check whether any record matching the queryable exists, with options.

Fetch a single record by primary key. Returns nil if not found.

Fetch a single record by primary key with options.

Fetch a single record by primary key, or dispatch Throw if not found.

Fetch a single record by primary key with options, or dispatch Throw.

Fetch a single record by the given clauses. Returns nil if not found.

Fetch a single record by the given clauses with options.

Fetch a single record by the given clauses, or dispatch Throw if not found.

Fetch a single record by the given clauses with options, or dispatch Throw.

Insert a new record from a changeset or struct.

Insert a new record from a changeset or struct with options.

Insert a new record, raising on failure. Mirrors Ecto.Repo.insert!/2.

Insert a new record with options, raising on failure.

Insert all entries into a schema or source at once.

Insert or update a record depending on whether it has been loaded.

Insert or update a record with options.

Insert or update a record, raising on failure.

Insert or update a record with options, raising on failure.

Load a schema struct or map from raw data. Mirrors Ecto.Repo.load/2.

Fetch a single result from a query. Returns nil if no result.

Fetch a single result from a query with options.

Fetch a single result from a query, or dispatch Throw if no result.

Fetch a single result from a query with options, or dispatch Throw.

Preload associations on a struct, list of structs, or nil.

Preload associations with options.

Execute a raw SQL query. Returns {:ok, result} | {:error, term()}.

Execute a raw SQL query with parameters.

Execute a raw SQL query with parameters and options.

Execute a raw SQL query, raising on error.

Execute a raw SQL query with parameters, raising on error.

Execute a raw SQL query with parameters and options, raising on error.

Reload a struct or list of structs from the data store.

Reload a struct or list of structs with options.

Reload a struct or list of structs, raising if any are not found.

Reload a struct or list of structs with options, raising if not found.

Return a lazy enumerable that emits all records matching a queryable.

Return a lazy enumerable with options.

Update an existing record from a changeset.

Update an existing record from a changeset with options.

Update an existing record, raising on failure. Mirrors Ecto.Repo.update!/2.

Update an existing record with options, raising on failure.

Update all records matching a queryable.

Functions

__key__(atom, struct_or_changeset)

Build a test stub key for the reload! port operation.

__key__(atom, struct_or_changeset, opts)

Build a test stub key for the load port operation.

__key__(atom, sql, params, opts)

Build a test stub key for the preload port operation.

__key__(atom, queryable, aggregate, field, opts)

Build a test stub key for the aggregate port operation.

aggregate(queryable, aggregate, field)

Calculate an aggregate over the given field.

aggregate(queryable, aggregate, field, opts)

@spec aggregate(
  Ecto.Queryable.t(),
  atom(),
  atom(),
  keyword()
) :: Skuld.Comp.Types.computation(term())

Calculate an aggregate over the given field with options.

all(queryable)

Fetch all records matching a queryable.

all(queryable, opts)

Fetch all records matching a queryable with options.

all_by(queryable, clauses)

Fetch all records matching the given clauses.

all_by(queryable, clauses, opts)

Fetch all records matching the given clauses with options.

delete(struct_or_changeset)

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

Delete a record or changeset.

delete(struct_or_changeset, opts)

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

Delete a record or changeset with options.

delete!(struct_or_changeset)

Delete a record or changeset, raising on failure. Mirrors Ecto.Repo.delete!/2.

delete!(struct_or_changeset, opts)

Delete a record or changeset with options, raising on failure.

delete_all(queryable, opts)

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

Delete all records matching a queryable.

exists?(queryable)

Check whether any record matching the queryable exists.

exists?(queryable, opts)

Check whether any record matching the queryable exists, with options.

get(queryable, id)

Fetch a single record by primary key. Returns nil if not found.

get(queryable, id, opts)

Fetch a single record by primary key with options.

get!(queryable, id)

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 instead of raising.

get!(queryable, id, opts)

Fetch a single record by primary key with options, or dispatch Throw.

get_by(queryable, clauses)

@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.

get_by(queryable, clauses, opts)

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

Fetch a single record by the given clauses with options.

get_by!(queryable, clauses)

Fetch a single record by the given clauses, or dispatch Throw if not found.

Mirrors Ecto.Repo.get_by!/2.

get_by!(queryable, clauses, opts)

Fetch a single record by the given clauses with options, or dispatch Throw.

insert(struct_or_changeset)

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

Insert a new record from a changeset or struct.

insert(struct_or_changeset, opts)

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

Insert a new record from a changeset or struct with options.

insert!(struct_or_changeset)

Insert a new record, raising on failure. Mirrors Ecto.Repo.insert!/2.

insert!(struct_or_changeset, opts)

Insert a new record with options, raising on failure.

insert_all(source, entries, opts)

@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.

insert_or_update(changeset)

@spec insert_or_update(Ecto.Changeset.t()) ::
  Skuld.Comp.Types.computation({:ok, struct()} | {:error, Ecto.Changeset.t()})

Insert or update a record depending on whether it has been loaded.

insert_or_update(changeset, opts)

@spec insert_or_update(
  Ecto.Changeset.t(),
  keyword()
) ::
  Skuld.Comp.Types.computation({:ok, struct()} | {:error, Ecto.Changeset.t()})

Insert or update a record with options.

insert_or_update!(changeset)

@spec insert_or_update!(Ecto.Changeset.t()) :: Skuld.Comp.Types.computation(struct())

Insert or update a record, raising on failure.

insert_or_update!(changeset, opts)

@spec insert_or_update!(
  Ecto.Changeset.t(),
  keyword()
) :: Skuld.Comp.Types.computation(struct())

Insert or update a record with options, raising on failure.

load(schema_or_map, data)

@spec load(
  module() | map(),
  map() | keyword() | {list(), list()}
) :: Skuld.Comp.Types.computation(struct() | map())

Load a schema struct or map from raw data. Mirrors Ecto.Repo.load/2.

one(queryable)

Fetch a single result from a query. Returns nil if no result.

one(queryable, opts)

Fetch a single result from a query with options.

one!(queryable)

Fetch a single result from a query, or dispatch Throw if no result.

Mirrors Ecto.Repo.one!/1.

one!(queryable, opts)

Fetch a single result from a query with options, or dispatch Throw.

preload(structs_or_struct_or_nil, preloads)

@spec preload(
  [struct()] | struct() | nil,
  term()
) :: Skuld.Comp.Types.computation([struct()] | struct() | nil)

Preload associations on a struct, list of structs, or nil.

preload(structs_or_struct_or_nil, preloads, opts)

@spec preload(
  [struct()] | struct() | nil,
  term(),
  keyword()
) :: Skuld.Comp.Types.computation([struct()] | struct() | nil)

Preload associations with options.

query(sql)

@spec query(String.t()) ::
  Skuld.Comp.Types.computation({:ok, term()} | {:error, term()})

Execute a raw SQL query. Returns {:ok, result} | {:error, term()}.

query(sql, params)

@spec query(String.t(), list()) ::
  Skuld.Comp.Types.computation({:ok, term()} | {:error, term()})

Execute a raw SQL query with parameters.

query(sql, params, opts)

@spec query(String.t(), list(), keyword()) ::
  Skuld.Comp.Types.computation({:ok, term()} | {:error, term()})

Execute a raw SQL query with parameters and options.

query!(sql)

Execute a raw SQL query, raising on error.

query!(sql, params)

@spec query!(String.t(), list()) :: Skuld.Comp.Types.computation(term())

Execute a raw SQL query with parameters, raising on error.

query!(sql, params, opts)

@spec query!(String.t(), list(), keyword()) :: Skuld.Comp.Types.computation(term())

Execute a raw SQL query with parameters and options, raising on error.

reload(struct_or_structs)

@spec reload(struct() | [struct()]) ::
  Skuld.Comp.Types.computation(struct() | nil | [struct() | nil])

Reload a struct or list of structs from the data store.

reload(struct_or_structs, opts)

@spec reload(
  struct() | [struct()],
  keyword()
) :: Skuld.Comp.Types.computation(struct() | nil | [struct() | nil])

Reload a struct or list of structs with options.

reload!(struct_or_structs)

@spec reload!(struct() | [struct()]) ::
  Skuld.Comp.Types.computation(struct() | [struct()])

Reload a struct or list of structs, raising if any are not found.

reload!(struct_or_structs, opts)

@spec reload!(
  struct() | [struct()],
  keyword()
) :: Skuld.Comp.Types.computation(struct() | [struct()])

Reload a struct or list of structs with options, raising if not found.

stream(queryable)

Return a lazy enumerable that emits all records matching a queryable.

stream(queryable, opts)

Return a lazy enumerable with options.

update(changeset)

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

Update an existing record from a changeset.

update(changeset, opts)

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

Update an existing record from a changeset with options.

update!(changeset)

Update an existing record, raising on failure. Mirrors Ecto.Repo.update!/2.

update!(changeset, opts)

Update an existing record with options, raising on failure.

update_all(queryable, updates, opts)

Update all records matching a queryable.