how to create mnesia table in Elixir?

3033 views database
5

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.

answered question

1 Answer

11

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 indexedy the node? by default. For more information, visit elixirschool.com/en/lessons/specifics/mnesia/#starting-mnesia

posted this

Have an answer?

JD

Please login first before posting an answer.