If I just query the Answer
directly it looks like this:
#ExEbau.Form.Answer<
documents: #Ash.NotLoaded<:relationship, field: :documents>,
question: #Ash.NotLoaded<:relationship, field: :question>,
document: #Ash.NotLoaded<:relationship, field: :document>,
documents_join_assoc: #Ash.NotLoaded<:relationship, field: :documents_join_assoc>,
__meta__: #Ecto.Schema.Metadata<:loaded, "caluma_form_answer">,
id: "0571220a-75d1-44ea-b004-efead8419c38",
question_id: "municipality",
value: "1206",
document_id: "d54b0af1-f33d-44c0-a9a9-b0b5237975a2",
aggregates: %{},
calculations: %{},
...
>
If I query this aggregation:
defmodule SomeResource do
aggregates do
first :municipality_answer, [:case, :document, :answers], :value,
filter: expr(question_id == ^@config.answer_slugs.municipality)
end
end
I get this:
#ExEbau.Core.Instance<
applicants: #Ash.NotLoaded<:calculation, field: :applicants>,
submit_date: #Ash.NotLoaded<:calculation, field: :submit_date>,
foobar2: #Ash.NotLoaded<:calculation, field: :foobar2>,
foobar: #Ash.NotLoaded<:calculation, field: :foobar>,
address: #Ash.NotLoaded<:calculation, field: :address>,
intent: #Ash.NotLoaded<:calculation, field: :intent>,
name: #Ash.NotLoaded<:calculation, field: :name>,
form: #Ash.NotLoaded<:aggregate, field: :form>,
object_street: #Ash.NotLoaded<:aggregate, field: :object_street>,
applicants_list: #Ash.NotLoaded<:aggregate, field: :applicants_list>,
municipality_answer: "\"1201\"",
location: [],
instance_state: #Ash.NotLoaded<:relationship, field: :instance_state>,
personalien_answers: #Ash.NotLoaded<:relationship, field: :personalien_answers>,
personalien_documents: #Ash.NotLoaded<:relationship, field: :personalien_documents>,
case: #Ash.NotLoaded<:relationship, field: :case>,
__meta__: #Ecto.Schema.Metadata<:loaded, "INSTANCE">,
id: 46268,
instance_state_id: 21,
case_id: "a12c32cc-8ac8-419c-b498-505aca548c46",
aggregates: %{},
calculations: %{},
...
>