Oban.Repo (Oban v2.4.0) View Source

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 Types

Specs

config() :: %{
  :repo => module(),
  optional(:get_dynamic_repo) => (() -> pid() | atom()),
  optional(:log) => false | Logger.level(),
  optional(:prefix) => binary(),
  optional(any()) => any()
}

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(config(), (() -> 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(config()) :: 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(
  config(),
  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(config(), 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

insert(config(), Ecto.Schema.t() | Ecto.Changeset.t(), Keyword.t()) ::
  {:ok, Ecto.Schema.t()} | {:error, Ecto.Changeset.t()}

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(
  config(),
  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(config(), 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

to_sql(conf, kind, queryable)

View Source (since 2.2.0)

Specs

to_sql(config(), :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(config(), (... -> 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(config(), 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(config(), Ecto.Queryable.t(), Keyword.t(), Keyword.t()) ::
  {integer(), nil | [term()]}

Wraps Ecto.Repo.update_all/3.