Customer Prepare:
@impl true
def prepare(query, opts, _context) do
query
|> Ash.Query.after_action(fn _query, results ->
Enum.map(results, fn result ->
{Map.fetch!(result, opts[:name]), Map.fetch!(result, opts[:id])}
end)
end)
end
call it in resource as follows
read :lookup do
prepare {WB.Ash.Preperations.Lookup, [id: :id, name: :country]}
end
The result is getting transformed but the out put is errorring as :
Bread Crumbs:
> Exception raised in: WB.Ash.Organization.Local.lookup
Unknown Error
* ** (CaseClauseError) no case clause matching: [{"Botswana", "019600e8-fa87-7f84-9ee0-aadfb43c2f61"}...]