Fl4m3Ph03n1x
Get all objects from ets table
Background
I have an ets table with several objects in it. I want to, with 1 single operation, retrieve all keys and objects my table has.
Using match
I tried using match like this:
table = :ets.new(:table, [:public])
:ets.insert(table, [{:a, 0}, {:b, 1}, {:c, 2}])
:ets.match(table, '$1')
However it always returns empty.
What am I doing wrong?
Marked As Solved
benwilson512
Author of Craft GraphQL APIs in Elixir with Absinthe
@Fl4m3Ph03n1x :ets.tab2list is the best way to dump a whole table. Setting that aside though, is the code you posted supposed to show the issue? You aren’t inserting anything into the table.
7
Also Liked
Sebb
for anyone (like me) wondering how this is done with :dets
:dets.foldl(fn elem, acc -> [elem | acc] end, [], t)
7
l3nz
Btw, your mistake was that it is:
:ets.match(table, :"$1")`
4
Fl4m3Ph03n1x
Thanks for the answer !
(also, fixed the bug, thanks for spotting it, my bad!)
1
Popular in Questions
can someone please explain to me how Enum.reduce works with maps
New
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
Hi,
is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
Hi there, I'm working through my first release with elixir/phoenix. I've built a release with distillery and found that it crashes when I...
New
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
I would like to know what is the best IDE for elixir development?
New
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Other popular topics
Hello!
tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability.
After spen...
New
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
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...
New
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New







