%{
~D[2024-03-11] => [
%{
id: "697757c9-fe23-43ce-9c51-747d25224967",
user: %{type: :relationship, __struct__: Ash.NotLoaded, field: :user},
title: "์ค๋ ๊ธฐ๋กํ ๋ด์ฉ",
__struct__: Dentallog.DentalDiary.Diary,
date_of_visited: ~D[2024-03-11],
calculations: %{},
aggregates: %{},
__metadata__: %{
selected: [:archived_at, :id, :title, :date_of_record, :date_of_visited, :pain_of_scale,
:memo, :doctor_opinion, :created_at, :updated_at, :user_id],
keyset: "g2o="
},
archived_at: nil,
__lateral_join_source__: nil,
__order__: nil,
created_at: ~U[2024-03-24 00:31:44.315150Z],
updated_at: ~U[2024-03-24 00:31:44.315150Z],
paper_trail_versions: %{
type: :relationship,
__struct__: Ash.NotLoaded,
field: :paper_trail_versions
},
__meta__: %{
state: :loaded,
context: nil,
prefix: nil,
source: "dental_diaries",
__struct__: Ecto.Schema.Metadata,
schema: Dentallog.DentalDiary.Diary
},
user_id: "83d1da63-39d3-4c27-bc93-3a72f70435fc",
date_of_record: ~D[2024-03-11],
doctor_opinion: "์์ฌ์ค์ด ๋ค์์ฃผ์ ๋ด์ํ๋ผ๊ณ ํ์ฌ",
memo: "์ค๋ ๊ฐ๋๋ฐ ์ถฉ์น๊ฐ ๋ง์์",
pain_of_scale: 5,
photos: %{type: :relationship, __struct__: Ash.NotLoaded, field: :photos}
},
%{
id: "a59f58cb-2348-44d0-9669-a805e7b97a74",
user: %{type: :relationship, __struct__: Ash.NotLoaded, field: :user},
title: "์ค๋ ๊ธฐ๋กํ ๋ด์ฉ",
__struct__: Dentallog.DentalDiary.Diary,
date_of_visited: ~D[2024-03-11],
calculations: %{},
aggregates: %{},
__metadata__: %{
selected: [:archived_at, :id, :title, :date_of_record, :date_of_visited, :pain_of_scale,
:memo, :doctor_opinion, :created_at, :updated_at, :user_id],
keyset: "g2o="
},
archived_at: nil,
__lateral_join_source__: nil,
__order__: nil,
created_at: ~U[2024-03-24 00:31:44.651395Z],
updated_at: ~U[2024-03-24 00:31:44.651395Z],
paper_trail_versions: %{
type: :relationship,
__struct__: Ash.NotLoaded,
field: :paper_trail_versions
},
__meta__: %{
state: :loaded,
context: nil,
prefix: nil,
source: "dental_diaries",
__struct__: Ecto.Schema.Metadata,
schema: Dentallog.DentalDiary.Diary
},
user_id: "83d1da63-39d3-4c27-bc93-3a72f70435fc",
date_of_record: ~D[2024-03-11],
doctor_opinion: "์์ฌ์ค์ด ๋ค์์ฃผ์ ๋ด์ํ๋ผ๊ณ ํ์ฌ",
memo: "์ค๋ ๊ฐ๋๋ฐ ์ถฉ์น๊ฐ ๋ง์์",
pain_of_scale: 5,
photos: %{type: :relationship, __struct__: Ash.NotLoaded, field: :photos}
}
],
~D[2024-03-12] => [
%{
id: "95eecd00-3a72-4f41-b958-050bf6793528",
user: %{type: :relationship, __struct__: Ash.NotLoaded, field: :user},
title: "์ค๋ ๊ธฐ๋กํ ๋ด์ฉ",
__struct__: Dentallog.DentalDiary.Diary,
date_of_visited: ~D[2024-03-12],
calculations: %{},
aggregates: %{},
__metadata__: %{
selected: [:archived_at, :id, :title, :date_of_record, :date_of_visited, :pain_of_scale,
:memo, :doctor_opinion, :created_at, :updated_at, :user_id],
keyset: "g2o="
},
archived_at: nil,
__lateral_join_source__: nil,
__order__: nil,
created_at: ~U[2024-03-24 00:31:44.881270Z],
updated_at: ~U[2024-03-24 00:31:44.881270Z],
paper_trail_versions: %{
type: :relationship,
__struct__: Ash.NotLoaded,
field: :paper_trail_versions
},
__meta__: %{
state: :loaded,
context: nil,
prefix: nil,
source: "dental_diaries",
__struct__: Ecto.Schema.Metadata,
schema: Dentallog.DentalDiary.Diary
},
user_id: "83d1da63-39d3-4c27-bc93-3a72f70435fc",
date_of_record: ~D[2024-03-11],
doctor_opinion: "์์ฌ์ค์ด ๋ค์์ฃผ์ ๋ด์ํ๋ผ๊ณ ํ์ฌ",
memo: "์ค๋ ๊ฐ๋๋ฐ ์ถฉ์น๊ฐ ๋ง์์",
pain_of_scale: 5,
photos: %{type: :relationship, __struct__: Ash.NotLoaded, field: :photos}
},
%{
id: "7a2951dc-4d58-49a1-aa44-ea18618d8a88",
user: %{type: :relationship, __struct__: Ash.NotLoaded, field: :user},
title: "์ค๋ ๊ธฐ๋กํ ๋ด์ฉ",
__struct__: Dentallog.DentalDiary.Diary,
date_of_visited: ~D[2024-03-12],
calculations: %{},
aggregates: %{},
__metadata__: %{
selected: [:archived_at, :id, :title, :date_of_record, :date_of_visited, :pain_of_scale,
:memo, :doctor_opinion, :created_at, :updated_at, :user_id],
keyset: "g2o="
},
archived_at: nil,
__lateral_join_source__: nil,
__order__: nil,
created_at: ~U[2024-03-24 00:31:45.128320Z],
updated_at: ~U[2024-03-24 00:31:45.128320Z],
paper_trail_versions: %{
type: :relationship,
__struct__: Ash.NotLoaded,
field: :paper_trail_versions
},
__meta__: %{
state: :loaded,
context: nil,
prefix: nil,
source: "dental_diaries",
__struct__: Ecto.Schema.Metadata,
schema: Dentallog.DentalDiary.Diary
},
user_id: "83d1da63-39d3-4c27-bc93-3a72f70435fc",
date_of_record: ~D[2024-03-11],
doctor_opinion: "์์ฌ์ค์ด ๋ค์์ฃผ์ ๋ด์ํ๋ผ๊ณ ํ์ฌ",
memo: "์ค๋ ๊ฐ๋๋ฐ ์ถฉ์น๊ฐ ๋ง์์",
pain_of_scale: 5,
photos: %{type: :relationship, __struct__: Ash.NotLoaded, field: :photos}
}
]
}
As far as grouping by date, I was successful.
and I donโt think I need pagination, now that I think about it.
because read the entire data when doing a groupby anyway.
The problem is when I return it to AshGraphql.
queries do
action :list_diary_group_by_visited_date, :group_by_date_of_visited
end
...
action :group_by_date_of_visited, {:array, :map} do
run fn input, context ->
diary_list = Dentallog.DentalDiary.Diary
|> Dentallog.DentalDiary.read!()
|> Enum.group_by(&(&1.date_of_visited))
diary_list = Jason.encode!(diary_list)
{:ok, diary_list}
end
end
The return value is in the form of a [JsonString!] and I would like to return it as a structure of my choice.
Do I need to have knowledge of Absinte to do this?