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.insert(
         Link.changeset(%Link{}, attrs)
    |> Ecto.Multi.run(
         fn repo,
            %{link: link} ->
           |> Ecto.Changeset.change(
                %{field: new_value}
           |> repo.update()
    |> 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} =
  |> ...
  |> Repo.transaction()
1 Like

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