houmanka
Can you please guide me in StreamData bind function?
From the example in the documentation, I can’t figure out how it could work.
Please check the following. I get error
** (ArgumentError) expected a generator, which can be a %StreamData{} struct, an atom, or a tuple with generators in it, but got: %{"asset_id" => ""}
which it make sense, however I don’t know how else I can do it.
project_gen = constant(%{"project_id" => project.id})
tasks_value_list = list_of(Factory.my_terms(), min_length: 5)
task_gen = map_of(constant("tasks"), tasks_value_list, length: 1)
asset_gen = map_of(constant("asset_id"), Factory.my_terms, length: 1)
data = bind(task_gen, fn(a_task_map_list) ->
bind(map_of(constant("asset_id"), Factory.my_terms, length: 1),
fn(an_asset) ->
list_of( map_of(an_asset, a_task_map_list), length: 1)
end)
end)
The above is the start of generating the following data structure:
%{"project_id" => project_id,
"tasks" => [ %{"asset_id" => 10, "tasks" => []},
%{"asset_id" => <<170, 87>>, "tasks" => [ <<203, 121>>, :L, :K6, 2, "%H" ]}
] }
Thank you in advance
Popular in Questions
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
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
Credo is smart enough to check for (something like) this:
assert length(the_list) == 0
with this response:
Checking if an enum is empt...
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
The Elixir Typespec docs show the following syntax for keyword lists in typespecs:
# ...
| [key: type] # keyword lis...
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
Hello everybody,
usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
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
Other popular topics
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
15:22:35.803 [error] gen_event {lager_file_backend...
New
can someone please explain to me how Enum.reduce works with maps
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 am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
by Lance Halvorsen
Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
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







