sendou.ink/app/db/models/calendar/findById.sql
2022-08-14 13:15:18 +03:00

31 lines
843 B
SQL

select
"CalendarEvent"."name",
"CalendarEvent"."description",
"CalendarEvent"."discordInviteCode",
"CalendarEvent"."discordUrl",
"CalendarEvent"."bracketUrl",
"CalendarEvent"."tags",
"CalendarEvent"."participantCount",
"User"."id" as "authorId",
exists (
select
1
from
"CalendarEventBadge"
where
"CalendarEventBadge"."eventId" = "CalendarEventDate"."eventId"
) as "hasBadge",
"CalendarEventDate"."startTime",
"CalendarEventDate"."eventId",
"User"."discordName",
"User"."discordDiscriminator",
"User"."discordId",
"User"."discordAvatar"
from
"CalendarEvent"
join "CalendarEventDate" on "CalendarEvent"."id" = "CalendarEventDate"."eventId"
join "User" on "CalendarEvent"."authorId" = "User"."id"
where
"CalendarEvent"."id" = @id
order by
"CalendarEventDate"."startTime" asc