Most efficient way to replace some values of a struct by other values of that struct

I have a list of structs as a result of a Repo.all() and I would like to copy some of their values to other key values.
I made up this code to illustrate what I intend:

fields_base = [:date, :text, :title]            #list with the keys I want to update their values
fields_langs = [:date_pt, :text_pt, :title_pt]  #list with the keys that contain the values I want to copy
        events = Data.listAll(Events)
        events = 
          for i <- events do
            %{i | i.fields_base[0] => i.fields_langs[0] }
          end
        events =
          for i <- events do
            %{i | i.fields_base[1] => i.fields_langs[1] }
          end
        events = 
          for i <- events do
            %{i | i.fields_base[2] => i.fields_langs[2] }
          end

I’m sure that Map could be useful here but I don’t know how to use it.

Instead of two lists with the keys, it’s better to use a map in order to make the relationship direct, and easier to enumerate over:

fields = %{date: :date_pt, text: :text_pt, title: :title_pt}

You only need to iterate over the events once. There are a number of ways to write this. Here’s one:

for i <- events do                                                                      
  fields
  |> Enum.map(fn {k,v} -> {k, Map.get(i, v)} end)
  |> Enum.into(Map.from_struct(i))
end

However, since your are using Ecto, you could also handle the renaming directly in the query.

Great!
Yes, as I’m learning I’m taking baby steps in here to get solid learning of the future but I realise I have two way of doing this:
a) with the query results, pure Elixir, no Ecto - what you just showed;
b) in the query itself - maybe more efficient because it’s just one step instead of two.
I’m still struggling with b). Do you have an alternative to a simple Repo.all(Events)?

There are some examples in the documentation for Ecto.Query.select/3.

Something similar to this:

import Ecto.Query
query = from(e in Event, select: %{title: e.title_pt, date: e.date_pt, text: e.text_pt})
events = Repo.all(query)

Note that this will only select those three fields for each Event record. You also end up with a map for each record, not an Event struct.