MailglassInbound.Repo (MailglassInbound v2.0.0)

Copy Markdown View Source

Thin facade over the host-configured repo for mailglass_inbound.

The sibling package does not own a repo. Host applications configure one via config :mailglass_inbound, :repo, MyApp.Repo.

Schema prefix injection (v2.0)

Every delegated read/write injects prefix: MailglassInbound.Config.schema() via Keyword.put_new, routing all operations to the configured Postgres schema ("mailglass" by default, "public" for pre-2.0 opt-out). An explicit caller-supplied :prefix wins over the injected default (INB-01).

transact/2 and multi/2 do NOT inject prefix. The inner insert/2, one/2, all/2, and get/3 calls inside a transaction carry their own prefix via the facade. Inbound has no Multi builders today (multi_opts/1 is deferred); a future raw caller that passes an inbound table to a non-facade path must qualify inline.

Summary

Functions

all(queryable, opts \\ [])

@spec all(
  Ecto.Queryable.t(),
  keyword()
) :: [struct()]

get(queryable, id, opts \\ [])

@spec get(Ecto.Queryable.t(), term(), keyword()) :: struct() | nil

insert(struct_or_changeset, opts \\ [])

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

multi(multi, opts \\ [])

@spec multi(
  Ecto.Multi.t(),
  keyword()
) :: {:ok, map()} | {:error, atom(), any(), map()}

one(queryable, opts \\ [])

@spec one(
  Ecto.Queryable.t(),
  keyword()
) :: struct() | nil

transact(fun, opts \\ [])

@spec transact(
  (-> {:ok, any()} | {:error, any()}),
  keyword()
) :: {:ok, any()} | {:error, any()}