expected v0.1.1 Expected.MnesiaStore.Helpers View Source
Helpers for creating the Mnesia table.
You can use the functions in this module to create the Mnesia table used by
Expected.MnesiaStore
on the current node. If you want more advanced features
like distribution, you should create the table yourself.
Link to this section Summary
Functions
Clears all logins from the table
Clears all logins from the Mnesia table given in the configuration
Drops the Mnesia table
Drops the Mnesia table given in the configuration
Creates a Mnesia table for login storage
Sets up the Mnesia table for login storage according to the configuration
Link to this section Functions
Clears all logins from the table
.
Clears all logins from the Mnesia table given in the configuration.
For this function to work, :table
must be set in your config.exs
:
config :expected,
store: :mnesia,
table: :logins,
...
Drops the Mnesia table
.
Drops the Mnesia table given in the configuration.
For this function to work, :table
must be set in your config.exs
:
config :expected,
store: :mnesia,
table: :logins,
...
setup(atom(), :persistent | :volatile) :: return_value()
Creates a Mnesia table for login storage.
Parameters
table
- Mnesia table namepersistent?
- persistence mode.:persistent
automatically sets the schema and the table to keep a copy of their data in both RAM and disk.:volatile
lets the schema copy mode untouched and creates a RAM-only login store.
Return values
:ok
- the table has been successfully created{:error, :already_exists}
- a table with the same name but different attribute already exists. If the table has the correct attributes, there is no error.- Any other error from Mnesia
Examples
iex> Expected.MnesiaStore.Helpers.setup(:logins)
:ok
iex> :mnesia.create_table(:test, [attributes: [:id, :data]])
{:atomic, :ok}
iex> Expected.MnesiaStore.Helpers.setup(:test)
{:error, already_exists}
Sets up the Mnesia table for login storage according to the configuration.
For this function to work, :table
must be set in your config.exs
:
config :expected,
store: :mnesia,
table: :logins,
...
It then creates a Mnesia table with copies in RAM and on disk, so that logins
are persistent accross application reboots. For more information about the
process, see setup/2
.
If the table already exists with different attributes, an
Expected.MnesiaTableExistsError
is raised.