View Source Oban.Repo (Oban v2.11.0)

Wrappers around Ecto.Repo callbacks.

These functions should be used when working with an Ecto repo inside a plugin. These functions will resolve the correct repo instance, and set the schema prefix and the log level, according to the Oban configuration.

Link to this section Summary

Link to this section Functions

Link to this function

all(conf, queryable, opts \\ [])

View Source (since 2.2.0)

Specs

Wraps Ecto.Repo.all/2.

Link to this function

checkout(conf, function, opts \\ [])

View Source (since 2.2.0)

Specs

checkout(Oban.Config.t(), (() -> result), Keyword.t()) :: result
when result: var

Wraps Ecto.Repo.checkout/2.

Link to this function

config(conf)

View Source (since 2.2.0)

Specs

config(Oban.Config.t()) :: Keyword.t()

Wraps Ecto.Repo.config/0.

Link to this function

delete(conf, struct_or_changeset, opts \\ [])

View Source (since 2.4.0)

Specs

delete(
  Oban.Config.t(),
  struct_or_changeset :: Ecto.Schema.t() | Ecto.Changeset.t(),
  opts :: Keyword.t()
) :: {:ok, Ecto.Schema.t()} | {:error, Ecto.Changeset.t()}

Wraps Ecto.Repo.delete/2.

Link to this function

delete_all(conf, queryable, opts \\ [])

View Source (since 2.2.0)

Specs

delete_all(Oban.Config.t(), Ecto.Queryable.t(), Keyword.t()) ::
  {integer(), nil | [term()]}

Wraps Ecto.Repo.delete_all/2.

Link to this function

insert(conf, struct_or_changeset, opts \\ [])

View Source (since 2.2.0)

Specs

Wraps Ecto.Repo.insert/2.

Link to this function

insert_all(conf, schema_or_source, entries, opts \\ [])

View Source (since 2.2.0)

Specs

insert_all(
  Oban.Config.t(),
  binary() | {binary(), module()} | module(),
  [map() | [{atom(), term() | Ecto.Query.t()}]],
  Keyword.t()
) :: {integer(), nil | [term()]}

Wraps Ecto.Repo.insert_all/3.

Link to this function

one(conf, queryable, opts \\ [])

View Source (since 2.2.0)

Specs

Wraps Ecto.Repo.one/2.

Link to this function

query(conf, sql, params \\ [], opts \\ [])

View Source (since 2.2.0)

Specs

query(Oban.Config.t(), String.t(), [term()], Keyword.t()) ::
  {:ok,
   %{
     :rows => nil | [[term()] | binary()],
     :num_rows => non_neg_integer(),
     optional(atom()) => any()
   }}
  | {:error, Exception.t()}

Wraps Ecto.Adapters.SQL.Repo.query/4.

Link to this function

stream(conf, queryable, opts \\ [])

View Source (since 2.9.0)

Specs

Wraps Ecto.Repo.stream/2

Link to this function

to_sql(conf, kind, queryable)

View Source (since 2.2.0)

Specs

to_sql(Oban.Config.t(), :all | :update_all | :delete_all, Ecto.Queryable.t()) ::
  {String.t(), [term()]}

Wraps Ecto.Adapters.SQL.Repo.to_sql/2.

Link to this function

transaction(conf, fun_or_multi, opts \\ [])

View Source (since 2.2.0)

Specs

transaction(
  Oban.Config.t(),
  (... -> any()) | Ecto.Multi.t(),
  opts :: Keyword.t()
) ::
  {:ok, any()}
  | {:error, any()}
  | {:error, Ecto.Multi.name(), any(), %{required(Ecto.Multi.name()) => any()}}

Wraps Ecto.Repo.transaction/2.

Link to this function

update(conf, changeset, opts \\ [])

View Source (since 2.2.0)

Specs

update(Oban.Config.t(), Ecto.Changeset.t(), Keyword.t()) ::
  {:ok, Ecto.Schema.t()} | {:error, Ecto.Changeset.t()}

Wraps Ecto.Repo.update/2.

Link to this function

update_all(conf, queryable, updates, opts \\ [])

View Source (since 2.2.0)

Specs

update_all(Oban.Config.t(), Ecto.Queryable.t(), Keyword.t(), Keyword.t()) ::
  {integer(), nil | [term()]}

Wraps Ecto.Repo.update_all/3.