How to create :mnesia
table in Elixir?
Is there a way to add indexes while creation?
For example I want to create a User table with few attributes.
Here is how to do it:
:mnesia.start
:mnesia.create_table(
User,
[{:disc_copies, [node()]},
attributes: [:id, :name, :job],
index: [:name, :job]
])
Note that first attribute will be indexed by default. For more information, visit elixirschool.com/en/lessons/specifics/mnesia/#starting-mnesia
You also need to create schema before creating the table. Note that first attribute will be indexedy the node? by default. For more information, visit elixirschool.com/en/lessons/specifics/mnesia/#starting-mnesia