Files
immich/server/src/queries/album.group.repository.sql
T
Jason Rasmussen 4a881022c3 feat: groups
2025-07-31 17:47:59 -04:00

88 lines
1.5 KiB
SQL

-- NOTE: This file is auto generated by ./sql-generator
-- AlbumGroupRepository.getAll
select
(
select
to_json(obj)
from
(
select
"group"."id",
"group"."name",
"group"."description"
from
"group"
where
"group"."id" = "album_group"."groupId"
) as obj
) as "group",
"album_group"."createdAt",
"album_group"."updatedAt"
from
"album_group"
inner join "group" on "album_group"."groupId" = "group"."id"
where
"albumId" = $1
order by
"group"."name"
-- AlbumGroupRepository.createAll
insert into
"album_group" ("albumId", "groupId", "role")
values
($1, $2, $3)
on conflict ("albumId", "groupId") do update
set
"role" = "excluded"."role"
returning
"createdAt",
"updatedAt",
(
select
to_json(obj)
from
(
select
"id",
"name",
"description"
from
"group"
where
"album_group"."groupId" = "group"."id"
) as obj
) as "group"
-- AlbumGroupRepository.deleteAll
delete from "album_group"
where
"albumId" = $1
and "groupId" in ($2)
-- AlbumGroupRepository.update
update "album_group"
set
"role" = $1
where
"albumId" = $2
and "groupId" = $3
returning
"createdAt",
"updatedAt",
(
select
to_json(obj)
from
(
select
"id",
"name",
"description"
from
"group"
where
"album_group"."groupId" = "group"."id"
) as obj
) as "group"