Update not return the updated field

update not return the new value in schema even given the returning: true or returning: [field] as option, not work either with read_after_writes: trueset in schema definition

    Ecto.Multi.new()
    |> Ecto.Multi.insert(
         :link,
         Link.changeset(%Link{}, attrs)
       )
    |> Ecto.Multi.run(
         :update,
         fn repo,
            %{link: link} ->
           ...
           link
           |> Ecto.Changeset.change(
                %{field: new_value}
              )
           |> repo.update()
         end
       )
    |> Repo.transaction()

I am not sure I get your problem. If you assign the result of the entire big pipe to a variable, you should get a map that has a :link key pointing to the newly created record and an :update key pointing to the updated record, like this:

%{link: created_record, update: updated_record} =
  Ecto.Multi.new()
  |> ...
  |> Repo.transaction()
1 Like

thanks @dimitarvp , I returned the wrong record (link/created_record)