Ecto.Adapters.Recall (Recall v0.1.0)

Copy Markdown View Source

An Ecto 3 adapter for Mnesia, the distributed, transactional database that ships with the BEAM.

Memory, recollected.

Unlike an ETS-backed adapter, Mnesia gives us real ACID transactions and optional disk persistence (disc_copies) for free — they map almost directly onto Ecto's Ecto.Adapter.Transaction and Ecto.Adapter.Storage behaviours. Query translation reuses Erlang match specifications, which Mnesia and ETS share verbatim.

Example

defmodule MyApp.Repo do
  use Ecto.Repo, otp_app: :my_app, adapter: Ecto.Adapters.Recall
end

Configuration

  • :storage:ram_copies (default), :disc_copies, or :disc_only_copies. Controls where auto-created tables live.
  • :type:ordered_set (default) or :set. :ordered_set keeps records in primary-key order, so reads come back sorted; falls back to :set for :disc_only_copies (which Mnesia doesn't allow with :ordered_set). A generated Recall.Schema can override it per table.
  • :nodes — list of nodes that hold copies (defaults to [node()]).
  • :dir — the Mnesia data directory (only relevant for disc storage).