Twfo326
Looking for MNESIA and AMNESIA learning resources
As a novice dev I’m trying to keep the curriculum as lean as possible.
My requirements are modest: build simple CRUD apps with Phoenix liveview, a key value store and auth. Scalability is a non concern.
MNESIA and AMNESIA seem like viable alternatives without the added learning overhead of SQL, Postgres, and Ecto.
But, I’m struggling to find practical learning resources, outside of these few:
I’d appreciate any other recommendations, the more project based/practical the better.
Most Liked
sheharyarn
Sebb
Twfo326
Thanks, this is exactly what I was looking for. Especially, “Erlang for Great Good!” - engaging, in depth and applied to a practical context that makes it easier to grok.
Twfo326
Thank you, this looks a lot more intuitive than vanilla Mnesia and I appreciate the effort that went into the docs.
Sebb
Just had a look at Memento.
I only did very basic stuff with ets/mnesia, but what bugged me were the match-specs.
Please correct if I’m wrong, but as I understand it …
if you got a table like this
Mnesia.create_table(Person, [attributes: [:id, :name, :job]])
and you want to query all persons with an :id > 3 you got to tell the match-spec about the structure you want to query by giving the positions of all attributes, these you can then in turn use in an expression.
Mnesia.dirty_select(Person, [{{Person, :"$1", :"$2", :"$3"}, [{:>, :"$1", 3}], [:"$$"]}])
This becomes annoying at the latest when you want to change the table, eg if you want to add an attribute you’d have to change all match-specs (add "$4" etc).
Helpers like :ets.fun2ms
iex> :ets.fun2ms(fn {id, name, job} when id > 3 -> {id, name, job} end)
[{{:"$1", :"$2", :"$3"}, [{:>, :"$1", 3}], [{{:"$1", :"$2", :"$3"}}]}]
or GitHub - ericmj/ex2ms: :ets.fun2ms for Elixir, translate functions to match specifications do not really help, because while they make it easier to write specs, you’ll still have to update when you change the table.
Memento keeps track of the positions of the table’s attributes so you can use keys in your queries:
Memento.Query.select(Person, [{:>, :id, 3}])
![]()







