Trying to select the age of patient, e.g.
from(
p in Patient
select: fragment("age(?)", p.dob),
where: [id: ^id]
)
|> Repo.one()
However, the %Struct{} returned from db needs to have all/most fields present, but I would rather avoid typing it out, e.g.
...
select: [p.name, p.email, fragment("age(?)", p.dob)]
...
Also, I would prefer if the query returns my %Struct{}. As it stand the select: [..fields..]
returns list.
Can anyone help?