select fields from nested associations
I have two tables:
Back to the point: I created a
The
Is there a way to modify the
In Ecto terms, would be something like:
I’ve tried many things without success — such as adding
users and user_profiles, with a one-to-one relationship. I know it might sound a bit silly, but I don't always need the information from the profile.Back to the point: I created a
read action for searching that looks like this:The
full_name is a calculation field based on other fields in user_profiles. For the search functionality, I only need the user's id and full_name — nothing more. However, when I trigger the search, it returns a whole bunch of fields, including full_name and all other user_profile fields.Is there a way to modify the
search so that it only returns a simple map with just the :id and :full_name fields?In Ecto terms, would be something like:
I’ve tried many things without success — such as adding
Ash.Query.select(:id) or using modify_query, but I’m not sure how to get an alias. Another option is to do some post-processing with Ecto.map, but I’m wondering if there’s a more elegant solution.