Twfo326

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

sheharyarn

I’m the author of Memento, an Elixir wrapper around :mnesia. I’ve written various use-cases and examples in the Memento docs, which might be somewhat useful.

Twfo326

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

Twfo326

Thank you, this looks a lot more intuitive than vanilla Mnesia and I appreciate the effort that went into the docs.

Sebb

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}])

:+1:

Where Next?

Popular in Chat/Questions Top

nur
https://e.planaria.network/stack.png https://e.planaria.network Build a NoSQL DB, Build a Relational SQL Database, Build a Graph Datab...
New
William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
New
markdev
What are the best beginner resources for learning Elixir and OTP (not Phoenix) in 2018?
New
mchean
I was wondering if anyone is using some learning tools that they can recommend? I’ve been looking at two specifically so would also be ...
New
gouvermxt
I just finished the “Learn Functional Programming with Elixir (Pragprog)” book. I have 5+ years of experience with Ruby/Rails, my goal is...
New
InkFlo
Hi everyone, This year I’m graduated from Bachelor Degree (in computer science) from France (not really a bachelor, the exact term is “L...
New
Nvim
Anybody know of a Pragmatic Studio 40% off coupon code for video course like Phoenix?
New
phykos
In Ruby, which is very similar to Elixir I do this: def test yield end test do puts("sup there") end Here, the yield keyword will be...
New
yachnytskyi
Hello everyone. I am gonna start with Elixir/Phoenix, thinking to use Stephen Grider as a start point, then elixir school and other sourc...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New

We're in Beta

About us Mission Statement