2023-11-30 10:10:30 -05:00
|
|
|
-- NOTE: This file is auto generated by ./sql-generator
|
|
|
|
|
|
|
|
|
|
-- SharedLinkRepository.get
|
2025-01-18 20:25:15 +01:00
|
|
|
select
|
|
|
|
|
"shared_links".*,
|
|
|
|
|
coalesce(
|
|
|
|
|
json_agg("a") filter (
|
|
|
|
|
where
|
|
|
|
|
"a"."id" is not null
|
|
|
|
|
),
|
|
|
|
|
'[]'
|
|
|
|
|
) as "assets",
|
|
|
|
|
to_json("album") as "album"
|
|
|
|
|
from
|
|
|
|
|
"shared_links"
|
|
|
|
|
left join lateral (
|
|
|
|
|
select
|
|
|
|
|
"assets".*,
|
|
|
|
|
to_json("exifInfo") as "exifInfo"
|
|
|
|
|
from
|
|
|
|
|
"shared_link__asset"
|
|
|
|
|
inner join "assets" on "assets"."id" = "shared_link__asset"."assetsId"
|
|
|
|
|
inner join lateral (
|
|
|
|
|
select
|
|
|
|
|
"exif".*
|
|
|
|
|
from
|
|
|
|
|
"exif"
|
|
|
|
|
where
|
|
|
|
|
"exif"."assetId" = "assets"."id"
|
|
|
|
|
) as "exifInfo" on true
|
|
|
|
|
where
|
|
|
|
|
"shared_links"."id" = "shared_link__asset"."sharedLinksId"
|
|
|
|
|
and "assets"."deletedAt" is null
|
|
|
|
|
order by
|
|
|
|
|
"assets"."fileCreatedAt" asc
|
|
|
|
|
) as "a" on true
|
|
|
|
|
left join lateral (
|
|
|
|
|
select
|
|
|
|
|
"albums".*,
|
|
|
|
|
coalesce(
|
|
|
|
|
json_agg("assets") filter (
|
|
|
|
|
where
|
|
|
|
|
"assets"."id" is not null
|
|
|
|
|
),
|
|
|
|
|
'[]'
|
|
|
|
|
) as "assets",
|
|
|
|
|
to_json("owner") as "owner"
|
|
|
|
|
from
|
|
|
|
|
"albums"
|
|
|
|
|
left join "albums_assets_assets" on "albums_assets_assets"."albumsId" = "albums"."id"
|
|
|
|
|
left join lateral (
|
|
|
|
|
select
|
|
|
|
|
"assets".*,
|
|
|
|
|
to_json("assets_exifInfo") as "exifInfo"
|
|
|
|
|
from
|
|
|
|
|
"assets"
|
|
|
|
|
inner join lateral (
|
|
|
|
|
select
|
|
|
|
|
"exif".*
|
|
|
|
|
from
|
|
|
|
|
"exif"
|
|
|
|
|
where
|
|
|
|
|
"exif"."assetId" = "assets"."id"
|
|
|
|
|
) as "assets_exifInfo" on true
|
|
|
|
|
where
|
|
|
|
|
"albums_assets_assets"."assetsId" = "assets"."id"
|
|
|
|
|
and "assets"."deletedAt" is null
|
|
|
|
|
order by
|
|
|
|
|
"assets"."fileCreatedAt" asc
|
|
|
|
|
) as "assets" on true
|
|
|
|
|
inner join lateral (
|
|
|
|
|
select
|
|
|
|
|
"users".*
|
|
|
|
|
from
|
|
|
|
|
"users"
|
|
|
|
|
where
|
|
|
|
|
"users"."id" = "albums"."ownerId"
|
|
|
|
|
and "users"."deletedAt" is null
|
|
|
|
|
) as "owner" on true
|
|
|
|
|
where
|
|
|
|
|
"albums"."id" = "shared_links"."albumId"
|
|
|
|
|
and "albums"."deletedAt" is null
|
|
|
|
|
group by
|
|
|
|
|
"albums"."id",
|
|
|
|
|
"owner".*
|
|
|
|
|
) as "album" on true
|
|
|
|
|
where
|
|
|
|
|
"shared_links"."id" = $1
|
|
|
|
|
and "shared_links"."userId" = $2
|
|
|
|
|
and (
|
|
|
|
|
"shared_links"."type" = $3
|
|
|
|
|
or "album"."id" is not null
|
|
|
|
|
)
|
|
|
|
|
group by
|
|
|
|
|
"shared_links"."id",
|
|
|
|
|
"album".*
|
|
|
|
|
order by
|
|
|
|
|
"shared_links"."createdAt" desc
|
2023-11-30 10:10:30 -05:00
|
|
|
|
|
|
|
|
-- SharedLinkRepository.getAll
|
2025-01-18 20:25:15 +01:00
|
|
|
select distinct
|
|
|
|
|
on ("shared_links"."createdAt") "shared_links".*,
|
2025-02-04 04:07:50 -05:00
|
|
|
to_json("assets") as "assets",
|
2025-01-18 20:25:15 +01:00
|
|
|
to_json("album") as "album"
|
|
|
|
|
from
|
|
|
|
|
"shared_links"
|
|
|
|
|
left join "shared_link__asset" on "shared_link__asset"."sharedLinksId" = "shared_links"."id"
|
|
|
|
|
left join lateral (
|
|
|
|
|
select
|
2025-02-04 04:07:50 -05:00
|
|
|
json_agg("assets") as "assets"
|
2025-01-18 20:25:15 +01:00
|
|
|
from
|
|
|
|
|
"assets"
|
|
|
|
|
where
|
|
|
|
|
"assets"."id" = "shared_link__asset"."assetsId"
|
|
|
|
|
and "assets"."deletedAt" is null
|
|
|
|
|
) as "assets" on true
|
|
|
|
|
left join lateral (
|
|
|
|
|
select
|
|
|
|
|
"albums".*,
|
|
|
|
|
to_json("owner") as "owner"
|
|
|
|
|
from
|
|
|
|
|
"albums"
|
|
|
|
|
inner join lateral (
|
|
|
|
|
select
|
|
|
|
|
"users"."id",
|
|
|
|
|
"users"."email",
|
|
|
|
|
"users"."createdAt",
|
|
|
|
|
"users"."profileImagePath",
|
|
|
|
|
"users"."isAdmin",
|
|
|
|
|
"users"."shouldChangePassword",
|
|
|
|
|
"users"."deletedAt",
|
|
|
|
|
"users"."oauthId",
|
|
|
|
|
"users"."updatedAt",
|
|
|
|
|
"users"."storageLabel",
|
|
|
|
|
"users"."name",
|
|
|
|
|
"users"."quotaSizeInBytes",
|
|
|
|
|
"users"."quotaUsageInBytes",
|
|
|
|
|
"users"."status",
|
|
|
|
|
"users"."profileChangedAt"
|
|
|
|
|
from
|
|
|
|
|
"users"
|
|
|
|
|
where
|
|
|
|
|
"users"."id" = "albums"."ownerId"
|
|
|
|
|
and "users"."deletedAt" is null
|
|
|
|
|
) as "owner" on true
|
|
|
|
|
where
|
|
|
|
|
"albums"."id" = "shared_links"."albumId"
|
|
|
|
|
and "albums"."deletedAt" is null
|
|
|
|
|
) as "album" on true
|
|
|
|
|
where
|
|
|
|
|
"shared_links"."userId" = $1
|
|
|
|
|
and (
|
|
|
|
|
"shared_links"."type" = $2
|
|
|
|
|
or "album"."id" is not null
|
2023-11-30 10:10:30 -05:00
|
|
|
)
|
2025-02-12 15:23:08 -05:00
|
|
|
and "shared_links"."albumId" = $3
|
2025-01-18 20:25:15 +01:00
|
|
|
order by
|
|
|
|
|
"shared_links"."createdAt" desc
|
2023-11-30 10:10:30 -05:00
|
|
|
|
|
|
|
|
-- SharedLinkRepository.getByKey
|
2025-01-18 20:25:15 +01:00
|
|
|
select
|
2025-02-12 15:23:08 -05:00
|
|
|
"shared_links"."id",
|
|
|
|
|
"shared_links"."userId",
|
|
|
|
|
"shared_links"."expiresAt",
|
|
|
|
|
"shared_links"."showExif",
|
|
|
|
|
"shared_links"."allowUpload",
|
|
|
|
|
"shared_links"."allowDownload",
|
|
|
|
|
"shared_links"."password",
|
2023-11-30 10:10:30 -05:00
|
|
|
(
|
2025-01-18 20:25:15 +01:00
|
|
|
select
|
|
|
|
|
to_json(obj)
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
"users"."id",
|
2025-02-12 15:23:08 -05:00
|
|
|
"users"."name",
|
2025-01-18 20:25:15 +01:00
|
|
|
"users"."email",
|
|
|
|
|
"users"."isAdmin",
|
|
|
|
|
"users"."quotaUsageInBytes",
|
2025-02-12 15:23:08 -05:00
|
|
|
"users"."quotaSizeInBytes"
|
2025-01-18 20:25:15 +01:00
|
|
|
from
|
|
|
|
|
"users"
|
|
|
|
|
where
|
|
|
|
|
"users"."id" = "shared_links"."userId"
|
|
|
|
|
) as obj
|
|
|
|
|
) as "user"
|
|
|
|
|
from
|
|
|
|
|
"shared_links"
|
|
|
|
|
left join "albums" on "albums"."id" = "shared_links"."albumId"
|
|
|
|
|
where
|
|
|
|
|
"shared_links"."key" = $1
|
|
|
|
|
and "albums"."deletedAt" is null
|
|
|
|
|
and (
|
|
|
|
|
"shared_links"."type" = $2
|
|
|
|
|
or "albums"."id" is not null
|
|
|
|
|
)
|