Pass along values with Ecto Multi

I can’t correctly pass values in between Ecto Multi run calls.

Below I return {ok, bar |> Repo.preload(:baz)} but in the next run call, :baz is not loaded:
|> Ecto.Multi.insert_or_update(:foo, foo_changeset)
|>, fn _repo, %{bar: bar} ->
  # some code
  {ok, bar |> Repo.preload(:baz)}
|>, fn _repo, %{bar: bar} ->
  IO.inspect bar # <---- `:baz` is not loaded
  {ok, bar}

Because it’s under the :add_something_to_foo key not :bar (:foo).

1 Like

Thank you fixed by replacing

|>, fn _repo, %{bar: bar} ->


|>, fn _repo, %{add_something_to_foo: bar} ->