A focused Elixir wrapper around the Erlang :mnesia
runtime database used by MishkaInstaller.
It exposes only what the installer needs and standardises a few outputs. The full API is split into:
MishkaInstaller.Helper.MnesiaAssistant.Schema— schema creationMishkaInstaller.Helper.MnesiaAssistant.Table— table create / wait / clear / keysMishkaInstaller.Helper.MnesiaAssistant.Query— read / write / delete / selectMishkaInstaller.Helper.MnesiaAssistant.Transaction— transaction / ets / error mappingMishkaInstaller.Helper.MnesiaAssistant.Information—system_infoMishkaInstaller.Helper.MnesiaAssistant.Error— error description + logging
Summary
Functions
Connects this (running, empty-schema) node to the cluster nodes. Delegates to
:mnesia.change_config/2. Returns {:ok, connected_nodes} or {:error, reason}.
Translates a result selector into the Erlang match-spec result body. See
MishkaInstaller.Helper.Extra.erlang_result/1.
Builds the head tuple of an Erlang match specification. See
MishkaInstaller.Helper.Extra.erlang_fields/4.
Starts the Mnesia application. Delegates to :mnesia.start/0.
Stops the Mnesia application. Delegates to :mnesia.stop/0.
Subscribes the calling process to Mnesia what events (e.g. :system).
Delegates to :mnesia.subscribe/1.
Converts Mnesia record tuples into maps or structs.
Unsubscribes from Mnesia what events. Delegates to :mnesia.unsubscribe/1.
Functions
Connects this (running, empty-schema) node to the cluster nodes. Delegates to
:mnesia.change_config/2. Returns {:ok, connected_nodes} or {:error, reason}.
Translates a result selector into the Erlang match-spec result body. See
MishkaInstaller.Helper.Extra.erlang_result/1.
Builds the head tuple of an Erlang match specification. See
MishkaInstaller.Helper.Extra.erlang_fields/4.
@spec start() :: :ok | {:error, term()}
Starts the Mnesia application. Delegates to :mnesia.start/0.
@spec stop() :: :stopped | {:error, term()}
Stops the Mnesia application. Delegates to :mnesia.stop/0.
Subscribes the calling process to Mnesia what events (e.g. :system).
Delegates to :mnesia.subscribe/1.
@spec tuple_to_map(list() | tuple() | :"$end_of_table", [atom()], module() | nil, [ atom() ]) :: list() | {list(), any()}
Converts Mnesia record tuples into maps or structs.
:"$end_of_table"becomes[].{records, cont}(a paginated select result) keeps the continuation:{converted, cont}.- a list of record tuples becomes a list; each tuple is zipped with
fields(the leading record tag is dropped),dropkeys are removed, and — whenstructis notnil— wrapped withstruct!/2.
Examples
iex> MishkaInstaller.Helper.MnesiaAssistant.tuple_to_map([{Person, 1, "a"}], [:id, :name], nil, [])
[%{id: 1, name: "a"}]
Unsubscribes from Mnesia what events. Delegates to :mnesia.unsubscribe/1.