Files
immich/server/src/queries/stack.repository.sql

146 lines
4.3 KiB
MySQL
Raw Normal View History

-- NOTE: This file is auto generated by ./sql-generator
-- StackRepository.search
select
2025-07-14 10:13:06 -04:00
"stack".*,
(
select
coalesce(json_agg(agg), '[]')
from
(
select
2025-07-14 10:13:06 -04:00
"asset".*,
to_json("exifInfo") as "exifInfo"
from
2025-07-14 10:13:06 -04:00
"asset"
inner join lateral (
select
2025-07-14 10:13:06 -04:00
"asset_exif"."assetId",
"asset_exif"."autoStackId",
"asset_exif"."bitsPerSample",
"asset_exif"."city",
"asset_exif"."colorspace",
"asset_exif"."country",
"asset_exif"."dateTimeOriginal",
"asset_exif"."description",
"asset_exif"."exifImageHeight",
"asset_exif"."exifImageWidth",
"asset_exif"."exposureTime",
"asset_exif"."fileSizeInByte",
"asset_exif"."fNumber",
"asset_exif"."focalLength",
"asset_exif"."fps",
"asset_exif"."iso",
"asset_exif"."latitude",
"asset_exif"."lensModel",
"asset_exif"."livePhotoCID",
"asset_exif"."longitude",
"asset_exif"."make",
"asset_exif"."model",
"asset_exif"."modifyDate",
"asset_exif"."orientation",
"asset_exif"."profileDescription",
"asset_exif"."projectionType",
"asset_exif"."rating",
"asset_exif"."state",
"asset_exif"."timeZone"
from
2025-07-14 10:13:06 -04:00
"asset_exif"
where
2025-07-14 10:13:06 -04:00
"asset_exif"."assetId" = "asset"."id"
) as "exifInfo" on true
where
2025-07-14 10:13:06 -04:00
"asset"."deletedAt" is null
and "asset"."stackId" = "stack"."id"
and "asset"."visibility" in ('archive', 'timeline')
) as agg
) as "assets"
from
2025-07-14 10:13:06 -04:00
"stack"
where
2025-07-14 10:13:06 -04:00
"stack"."ownerId" = $1
-- StackRepository.delete
2025-07-14 10:13:06 -04:00
delete from "stack"
where
"id" = $1::uuid
-- StackRepository.getById
select
*,
(
select
coalesce(json_agg(agg), '[]')
from
(
select
2025-07-14 10:13:06 -04:00
"asset".*,
(
select
coalesce(json_agg(agg), '[]')
from
(
select
2025-07-14 10:13:06 -04:00
"tag"."id",
"tag"."value",
"tag"."createdAt",
"tag"."updatedAt",
"tag"."color",
"tag"."parentId"
from
2025-07-14 10:13:06 -04:00
"tag"
inner join "tag_asset" on "tag"."id" = "tag_asset"."tagsId"
where
2025-07-14 10:13:06 -04:00
"tag_asset"."assetsId" = "asset"."id"
) as agg
) as "tags",
to_json("exifInfo") as "exifInfo"
from
2025-07-14 10:13:06 -04:00
"asset"
inner join lateral (
select
2025-07-14 10:13:06 -04:00
"asset_exif"."assetId",
"asset_exif"."autoStackId",
"asset_exif"."bitsPerSample",
"asset_exif"."city",
"asset_exif"."colorspace",
"asset_exif"."country",
"asset_exif"."dateTimeOriginal",
"asset_exif"."description",
"asset_exif"."exifImageHeight",
"asset_exif"."exifImageWidth",
"asset_exif"."exposureTime",
"asset_exif"."fileSizeInByte",
"asset_exif"."fNumber",
"asset_exif"."focalLength",
"asset_exif"."fps",
"asset_exif"."iso",
"asset_exif"."latitude",
"asset_exif"."lensModel",
"asset_exif"."livePhotoCID",
"asset_exif"."longitude",
"asset_exif"."make",
"asset_exif"."model",
"asset_exif"."modifyDate",
"asset_exif"."orientation",
"asset_exif"."profileDescription",
"asset_exif"."projectionType",
"asset_exif"."rating",
"asset_exif"."state",
"asset_exif"."timeZone"
from
2025-07-14 10:13:06 -04:00
"asset_exif"
where
2025-07-14 10:13:06 -04:00
"asset_exif"."assetId" = "asset"."id"
) as "exifInfo" on true
where
2025-07-14 10:13:06 -04:00
"asset"."deletedAt" is null
and "asset"."stackId" = "stack"."id"
and "asset"."visibility" in ('archive', 'timeline')
) as agg
) as "assets"
from
2025-07-14 10:13:06 -04:00
"stack"
where
"id" = $1::uuid