I have this struct of preload records.
I want to remove __meta__ and Ecto.Association.NotLoaded from the main struct as well as from the nested array of preloaded records. To make it a simple map
%Facility{
__meta__: #Ecto.Schema.Metadata<:loaded, "facilities">,
id: 4875,
instance: #Ecto.Association.NotLoaded<association :instance is not loaded>,
name: "Facility",
units: [
%Unit{
__meta__: #Ecto.Schema.Metadata<:loaded, "units">,
facility: #Ecto.Association.NotLoaded<association :facility is not loaded>,
facility_id: 4875,
id: 1593,
name: "Storage",
rooms: #Ecto.Association.NotLoaded<association :rooms is not loaded>
},
%Unit{
__meta__: #Ecto.Schema.Metadata<:loaded, "units">,
cdc_location_class_id: nil,
facility: #Ecto.Association.NotLoaded<association :facility is not loaded>,
facility_id: 4875,
id: 1594,
name: "Storage unit",
rooms: #Ecto.Association.NotLoaded<association :rooms is not loaded>
}
],
users: #Ecto.Association.NotLoaded<association :users is not loaded>
}
If i added them in the reverse order then it should be a list. i want it to be a map. Params come from the function. And I want it to manipulate it and add list of items in it like the example above…