sendou.ink/app/db/models/calendar/findRecentMapPoolsByAuthorId.sql
2022-10-27 13:31:37 +02:00

21 lines
428 B
SQL

select
"CalendarEvent"."id",
"CalendarEvent"."name",
json_group_array(
json_object(
'stageId',
"MapPoolMap"."stageId",
'mode',
"MapPoolMap"."mode"
)
) as "mapPool"
from
"CalendarEvent"
join "MapPoolMap" on "CalendarEvent"."id" = "MapPoolMap"."calendarEventId"
where
"CalendarEvent"."authorId" = @authorId
group by
"CalendarEvent"."id"
order by
"CalendarEvent"."id" desc
limit 5