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
Hello, I get Persian date from my client and convert it to normal calendar like this:
def jalali_string_to_miladi_english_number(persi...
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
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
I have followed this StackOverflow post to install the specific version of Erlang.
And When I am running mix ecto.setup then getting fol...
New
As a follow up to my earlier question:
I have the code compiling and running but not getting a successful login from the rest server. ...
New
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
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
Hi all
I want to have a unix time, from the current time plus 1 hour.
DateTime.now + 1 hour
How to get it in elixir?
Thanks
New
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
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
Other popular topics
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
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
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine)
This is a plugin that adds support for Elixir to JetBrains IntelliJ...
New
As a follow up to my earlier question:
I have the code compiling and running but not getting a successful login from the rest server. ...
New
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
I have a User schema with a :from_id field set to type :string:
defmodule TweetBot.Repo.Migrations.CreateUsers do
use Ecto.Migration
...
New
I tried installing
elixir 1.11.2
erlang 23.3.4
via asdf in my zsh shell. Enabled the versions locally and globally.
When I list them ...
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
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New








