Whatever your opinion of Mnesia is, has anyone used joins via qlc - query list comprehension - in an Elixir form?
It appears based on this thread that qlc operates on Erlang style list comprehensions instead of Elixir style. I noticed this Qlc library but this is also Erlang style.
Just curious if anyone has tried this out in Elixir and curious as to the build steps. Without being able to join tables here with qlc wondering how people are joining tables in Mnesia land…
Here’s some erlang qlc from the mnesia chapter of Programming Erlang
do(qlc:q([X#shop.item || X <- mnesia:table(shop),
X#shop.quantity < 250,
Y <- mnesia:table(cost),
X#shop.item =:= Y#cost.name,
Y#cost.price < 2
and the equivalent SQL
SELECT shop.item, shop.quantity, cost.name, cost.price
FROM shop, cost
WHERE shop.item = cost.name
AND cost.price < 2
AND shop.quantity < 250
Perhaps this is the way to go about querying via the Ecto Mnesia adapter ???
Automatically converts Ecto.Query structs to Erlang match_spec. Also adapter emulates query.select and query.order_bys behaviours, even though Mnesia itself does not support them.
Upon further read, it looks like Amnesia supports this, just need to figure out how to go about using the selection constructs with join
# You can also use an Exquisite selector to fetch records.
selection = Message.where user_id == 1 or user_id == 2,
# Get the values in the selector and print them.
selection |> Amnesia.Selection.values |> Enum.each &IO.puts(&1.content)
Does this code actually works ? For me, it’s not. My frustation with Amnesia library is growing… in Erlang it’s working so smoothly