2023-11-30 10:10:30 -05:00
|
|
|
-- NOTE: This file is auto generated by ./sql-generator
|
|
|
|
|
|
|
|
|
|
-- AlbumRepository.getById
|
2025-01-21 11:24:48 -06:00
|
|
|
select
|
|
|
|
|
"albums".*,
|
2023-11-30 10:10:30 -05:00
|
|
|
(
|
2025-01-21 11:24:48 -06:00
|
|
|
select
|
|
|
|
|
to_json(obj)
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
"id",
|
|
|
|
|
"email",
|
|
|
|
|
"createdAt",
|
|
|
|
|
"profileImagePath",
|
|
|
|
|
"isAdmin",
|
|
|
|
|
"shouldChangePassword",
|
|
|
|
|
"deletedAt",
|
|
|
|
|
"oauthId",
|
|
|
|
|
"updatedAt",
|
|
|
|
|
"storageLabel",
|
|
|
|
|
"name",
|
|
|
|
|
"quotaSizeInBytes",
|
|
|
|
|
"quotaUsageInBytes",
|
|
|
|
|
"status",
|
|
|
|
|
"profileChangedAt"
|
|
|
|
|
from
|
|
|
|
|
"users"
|
|
|
|
|
where
|
|
|
|
|
"users"."id" = "albums"."ownerId"
|
|
|
|
|
) as obj
|
|
|
|
|
) as "owner",
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
coalesce(json_agg(agg), '[]')
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
"album_users".*,
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
to_json(obj)
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
"id",
|
|
|
|
|
"email",
|
|
|
|
|
"createdAt",
|
|
|
|
|
"profileImagePath",
|
|
|
|
|
"isAdmin",
|
|
|
|
|
"shouldChangePassword",
|
|
|
|
|
"deletedAt",
|
|
|
|
|
"oauthId",
|
|
|
|
|
"updatedAt",
|
|
|
|
|
"storageLabel",
|
|
|
|
|
"name",
|
|
|
|
|
"quotaSizeInBytes",
|
|
|
|
|
"quotaUsageInBytes",
|
|
|
|
|
"status",
|
|
|
|
|
"profileChangedAt"
|
|
|
|
|
from
|
|
|
|
|
"users"
|
|
|
|
|
where
|
|
|
|
|
"users"."id" = "album_users"."usersId"
|
|
|
|
|
) as obj
|
|
|
|
|
) as "user"
|
|
|
|
|
from
|
|
|
|
|
"albums_shared_users_users" as "album_users"
|
|
|
|
|
where
|
|
|
|
|
"album_users"."albumsId" = "albums"."id"
|
|
|
|
|
) as agg
|
|
|
|
|
) as "albumUsers",
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
coalesce(json_agg(agg), '[]')
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
*
|
|
|
|
|
from
|
|
|
|
|
"shared_links"
|
|
|
|
|
where
|
|
|
|
|
"shared_links"."albumId" = "albums"."id"
|
|
|
|
|
) as agg
|
2025-01-22 15:17:42 -05:00
|
|
|
) as "sharedLinks",
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
json_agg("asset") as "assets"
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
"assets".*,
|
|
|
|
|
to_json("exif") as "exifInfo"
|
|
|
|
|
from
|
|
|
|
|
"assets"
|
|
|
|
|
inner join "exif" on "assets"."id" = "exif"."assetId"
|
|
|
|
|
inner join "albums_assets_assets" on "albums_assets_assets"."assetsId" = "assets"."id"
|
|
|
|
|
where
|
|
|
|
|
"albums_assets_assets"."albumsId" = "albums"."id"
|
|
|
|
|
and "assets"."deletedAt" is null
|
|
|
|
|
order by
|
|
|
|
|
"assets"."fileCreatedAt" desc
|
|
|
|
|
) as "asset"
|
|
|
|
|
) as "assets"
|
2025-01-21 11:24:48 -06:00
|
|
|
from
|
|
|
|
|
"albums"
|
|
|
|
|
where
|
2025-01-24 11:54:53 -06:00
|
|
|
"albums"."id" = $1
|
2025-01-21 11:24:48 -06:00
|
|
|
and "albums"."deletedAt" is null
|
2023-11-30 10:10:30 -05:00
|
|
|
|
|
|
|
|
-- AlbumRepository.getByAssetId
|
2025-01-21 11:24:48 -06:00
|
|
|
select
|
|
|
|
|
"albums".*,
|
2023-11-30 10:10:30 -05:00
|
|
|
(
|
2025-01-21 11:24:48 -06:00
|
|
|
select
|
|
|
|
|
to_json(obj)
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
"id",
|
|
|
|
|
"email",
|
|
|
|
|
"createdAt",
|
|
|
|
|
"profileImagePath",
|
|
|
|
|
"isAdmin",
|
|
|
|
|
"shouldChangePassword",
|
|
|
|
|
"deletedAt",
|
|
|
|
|
"oauthId",
|
|
|
|
|
"updatedAt",
|
|
|
|
|
"storageLabel",
|
|
|
|
|
"name",
|
|
|
|
|
"quotaSizeInBytes",
|
|
|
|
|
"quotaUsageInBytes",
|
|
|
|
|
"status",
|
|
|
|
|
"profileChangedAt"
|
|
|
|
|
from
|
|
|
|
|
"users"
|
|
|
|
|
where
|
|
|
|
|
"users"."id" = "albums"."ownerId"
|
|
|
|
|
) as obj
|
|
|
|
|
) as "owner",
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
coalesce(json_agg(agg), '[]')
|
|
|
|
|
from
|
2023-11-30 10:10:30 -05:00
|
|
|
(
|
2025-01-21 11:24:48 -06:00
|
|
|
select
|
|
|
|
|
"album_users".*,
|
2024-02-06 22:06:02 +00:00
|
|
|
(
|
2025-01-21 11:24:48 -06:00
|
|
|
select
|
|
|
|
|
to_json(obj)
|
|
|
|
|
from
|
2024-04-25 06:19:49 +02:00
|
|
|
(
|
2025-01-21 11:24:48 -06:00
|
|
|
select
|
|
|
|
|
"id",
|
|
|
|
|
"email",
|
|
|
|
|
"createdAt",
|
|
|
|
|
"profileImagePath",
|
|
|
|
|
"isAdmin",
|
|
|
|
|
"shouldChangePassword",
|
|
|
|
|
"deletedAt",
|
|
|
|
|
"oauthId",
|
|
|
|
|
"updatedAt",
|
|
|
|
|
"storageLabel",
|
|
|
|
|
"name",
|
|
|
|
|
"quotaSizeInBytes",
|
|
|
|
|
"quotaUsageInBytes",
|
|
|
|
|
"status",
|
|
|
|
|
"profileChangedAt"
|
|
|
|
|
from
|
|
|
|
|
"users"
|
|
|
|
|
where
|
|
|
|
|
"users"."id" = "album_users"."usersId"
|
|
|
|
|
) as obj
|
|
|
|
|
) as "user"
|
|
|
|
|
from
|
|
|
|
|
"albums_shared_users_users" as "album_users"
|
|
|
|
|
where
|
|
|
|
|
"album_users"."albumsId" = "albums"."id"
|
|
|
|
|
) as agg
|
|
|
|
|
) as "albumUsers"
|
|
|
|
|
from
|
|
|
|
|
"albums"
|
|
|
|
|
left join "albums_assets_assets" as "album_assets" on "album_assets"."albumsId" = "albums"."id"
|
|
|
|
|
left join "albums_shared_users_users" as "album_users" on "album_users"."albumsId" = "albums"."id"
|
|
|
|
|
where
|
|
|
|
|
(
|
|
|
|
|
(
|
|
|
|
|
"albums"."ownerId" = $1
|
|
|
|
|
and "album_assets"."assetsId" = $2
|
|
|
|
|
)
|
|
|
|
|
or (
|
|
|
|
|
"album_users"."usersId" = $3
|
|
|
|
|
and "album_assets"."assetsId" = $4
|
2023-11-30 10:10:30 -05:00
|
|
|
)
|
|
|
|
|
)
|
2025-01-21 11:24:48 -06:00
|
|
|
and "albums"."deletedAt" is null
|
|
|
|
|
order by
|
|
|
|
|
"albums"."createdAt" desc,
|
|
|
|
|
"albums"."createdAt" desc
|
2023-11-30 10:10:30 -05:00
|
|
|
|
|
|
|
|
-- AlbumRepository.getMetadataForIds
|
2025-01-21 11:24:48 -06:00
|
|
|
select
|
|
|
|
|
"albums"."id",
|
|
|
|
|
min("assets"."fileCreatedAt") as "startDate",
|
|
|
|
|
max("assets"."fileCreatedAt") as "endDate",
|
|
|
|
|
count("assets"."id") as "assetCount"
|
|
|
|
|
from
|
|
|
|
|
"albums"
|
|
|
|
|
left join "albums_assets_assets" as "album_assets" on "album_assets"."albumsId" = "albums"."id"
|
|
|
|
|
left join "assets" on "assets"."id" = "album_assets"."assetsId"
|
|
|
|
|
where
|
|
|
|
|
"albums"."id" in ($1)
|
2025-01-25 23:45:13 +01:00
|
|
|
and "assets"."deletedAt" is null
|
2025-01-21 11:24:48 -06:00
|
|
|
group by
|
|
|
|
|
"albums"."id"
|
2023-11-30 10:10:30 -05:00
|
|
|
|
|
|
|
|
-- AlbumRepository.getOwned
|
2025-01-21 11:24:48 -06:00
|
|
|
select
|
|
|
|
|
"albums".*,
|
2023-11-30 10:10:30 -05:00
|
|
|
(
|
2025-01-21 11:24:48 -06:00
|
|
|
select
|
|
|
|
|
to_json(obj)
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
"id",
|
|
|
|
|
"email",
|
|
|
|
|
"createdAt",
|
|
|
|
|
"profileImagePath",
|
|
|
|
|
"isAdmin",
|
|
|
|
|
"shouldChangePassword",
|
|
|
|
|
"deletedAt",
|
|
|
|
|
"oauthId",
|
|
|
|
|
"updatedAt",
|
|
|
|
|
"storageLabel",
|
|
|
|
|
"name",
|
|
|
|
|
"quotaSizeInBytes",
|
|
|
|
|
"quotaUsageInBytes",
|
|
|
|
|
"status",
|
|
|
|
|
"profileChangedAt"
|
|
|
|
|
from
|
|
|
|
|
"users"
|
|
|
|
|
where
|
|
|
|
|
"users"."id" = "albums"."ownerId"
|
|
|
|
|
) as obj
|
|
|
|
|
) as "owner",
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
coalesce(json_agg(agg), '[]')
|
|
|
|
|
from
|
2024-02-06 22:06:02 +00:00
|
|
|
(
|
2025-01-21 11:24:48 -06:00
|
|
|
select
|
|
|
|
|
"album_users".*,
|
2024-02-06 22:06:02 +00:00
|
|
|
(
|
2025-01-21 11:24:48 -06:00
|
|
|
select
|
|
|
|
|
to_json(obj)
|
|
|
|
|
from
|
2024-04-25 06:19:49 +02:00
|
|
|
(
|
2025-01-21 11:24:48 -06:00
|
|
|
select
|
|
|
|
|
"id",
|
|
|
|
|
"email",
|
|
|
|
|
"createdAt",
|
|
|
|
|
"profileImagePath",
|
|
|
|
|
"isAdmin",
|
|
|
|
|
"shouldChangePassword",
|
|
|
|
|
"deletedAt",
|
|
|
|
|
"oauthId",
|
|
|
|
|
"updatedAt",
|
|
|
|
|
"storageLabel",
|
|
|
|
|
"name",
|
|
|
|
|
"quotaSizeInBytes",
|
|
|
|
|
"quotaUsageInBytes",
|
|
|
|
|
"status",
|
|
|
|
|
"profileChangedAt"
|
|
|
|
|
from
|
|
|
|
|
"users"
|
|
|
|
|
where
|
|
|
|
|
"users"."id" = "album_users"."usersId"
|
|
|
|
|
) as obj
|
|
|
|
|
) as "user"
|
|
|
|
|
from
|
|
|
|
|
"albums_shared_users_users" as "album_users"
|
|
|
|
|
where
|
|
|
|
|
"album_users"."albumsId" = "albums"."id"
|
|
|
|
|
) as agg
|
|
|
|
|
) as "albumUsers",
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
coalesce(json_agg(agg), '[]')
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
*
|
|
|
|
|
from
|
|
|
|
|
"shared_links"
|
|
|
|
|
where
|
|
|
|
|
"shared_links"."albumId" = "albums"."id"
|
|
|
|
|
) as agg
|
|
|
|
|
) as "sharedLinks"
|
|
|
|
|
from
|
|
|
|
|
"albums"
|
|
|
|
|
where
|
|
|
|
|
"albums"."ownerId" = $1
|
|
|
|
|
and "albums"."deletedAt" is null
|
|
|
|
|
order by
|
|
|
|
|
"albums"."createdAt" desc
|
|
|
|
|
|
|
|
|
|
-- AlbumRepository.getShared
|
|
|
|
|
select distinct
|
|
|
|
|
on ("albums"."createdAt") "albums".*,
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
coalesce(json_agg(agg), '[]')
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
"album_users".*,
|
2024-02-06 22:06:02 +00:00
|
|
|
(
|
2025-01-21 11:24:48 -06:00
|
|
|
select
|
|
|
|
|
to_json(obj)
|
|
|
|
|
from
|
2024-02-06 22:06:02 +00:00
|
|
|
(
|
2025-01-21 11:24:48 -06:00
|
|
|
select
|
|
|
|
|
"id",
|
|
|
|
|
"email",
|
|
|
|
|
"createdAt",
|
|
|
|
|
"profileImagePath",
|
|
|
|
|
"isAdmin",
|
|
|
|
|
"shouldChangePassword",
|
|
|
|
|
"deletedAt",
|
|
|
|
|
"oauthId",
|
|
|
|
|
"updatedAt",
|
|
|
|
|
"storageLabel",
|
|
|
|
|
"name",
|
|
|
|
|
"quotaSizeInBytes",
|
|
|
|
|
"quotaUsageInBytes",
|
|
|
|
|
"status",
|
|
|
|
|
"profileChangedAt"
|
|
|
|
|
from
|
|
|
|
|
"users"
|
|
|
|
|
where
|
|
|
|
|
"users"."id" = "album_users"."usersId"
|
|
|
|
|
) as obj
|
|
|
|
|
) as "user"
|
|
|
|
|
from
|
|
|
|
|
"albums_shared_users_users" as "album_users"
|
|
|
|
|
where
|
|
|
|
|
"album_users"."albumsId" = "albums"."id"
|
|
|
|
|
) as agg
|
|
|
|
|
) as "albumUsers",
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
to_json(obj)
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
"id",
|
|
|
|
|
"email",
|
|
|
|
|
"createdAt",
|
|
|
|
|
"profileImagePath",
|
|
|
|
|
"isAdmin",
|
|
|
|
|
"shouldChangePassword",
|
|
|
|
|
"deletedAt",
|
|
|
|
|
"oauthId",
|
|
|
|
|
"updatedAt",
|
|
|
|
|
"storageLabel",
|
|
|
|
|
"name",
|
|
|
|
|
"quotaSizeInBytes",
|
|
|
|
|
"quotaUsageInBytes",
|
|
|
|
|
"status",
|
|
|
|
|
"profileChangedAt"
|
|
|
|
|
from
|
|
|
|
|
"users"
|
|
|
|
|
where
|
|
|
|
|
"users"."id" = "albums"."ownerId"
|
|
|
|
|
) as obj
|
|
|
|
|
) as "owner",
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
coalesce(json_agg(agg), '[]')
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
*
|
|
|
|
|
from
|
|
|
|
|
"shared_links"
|
|
|
|
|
where
|
|
|
|
|
"shared_links"."albumId" = "albums"."id"
|
|
|
|
|
) as agg
|
|
|
|
|
) as "sharedLinks"
|
|
|
|
|
from
|
|
|
|
|
"albums"
|
|
|
|
|
left join "albums_shared_users_users" as "shared_albums" on "shared_albums"."albumsId" = "albums"."id"
|
|
|
|
|
left join "shared_links" on "shared_links"."albumId" = "albums"."id"
|
|
|
|
|
where
|
|
|
|
|
(
|
|
|
|
|
"shared_albums"."usersId" = $1
|
|
|
|
|
or "shared_links"."userId" = $2
|
|
|
|
|
or (
|
|
|
|
|
"albums"."ownerId" = $3
|
|
|
|
|
and "shared_albums"."usersId" is not null
|
2023-11-30 10:10:30 -05:00
|
|
|
)
|
|
|
|
|
)
|
2025-01-21 11:24:48 -06:00
|
|
|
and "albums"."deletedAt" is null
|
|
|
|
|
order by
|
|
|
|
|
"albums"."createdAt" desc
|
2023-11-30 10:10:30 -05:00
|
|
|
|
|
|
|
|
-- AlbumRepository.getNotShared
|
2025-01-21 11:24:48 -06:00
|
|
|
select distinct
|
|
|
|
|
on ("albums"."createdAt") "albums".*,
|
2023-11-30 10:10:30 -05:00
|
|
|
(
|
2025-01-21 11:24:48 -06:00
|
|
|
select
|
|
|
|
|
coalesce(json_agg(agg), '[]')
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
"album_users".*,
|
2024-02-06 22:06:02 +00:00
|
|
|
(
|
2025-01-21 11:24:48 -06:00
|
|
|
select
|
|
|
|
|
to_json(obj)
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
"id",
|
|
|
|
|
"email",
|
|
|
|
|
"createdAt",
|
|
|
|
|
"profileImagePath",
|
|
|
|
|
"isAdmin",
|
|
|
|
|
"shouldChangePassword",
|
|
|
|
|
"deletedAt",
|
|
|
|
|
"oauthId",
|
|
|
|
|
"updatedAt",
|
|
|
|
|
"storageLabel",
|
|
|
|
|
"name",
|
|
|
|
|
"quotaSizeInBytes",
|
|
|
|
|
"quotaUsageInBytes",
|
|
|
|
|
"status",
|
|
|
|
|
"profileChangedAt"
|
|
|
|
|
from
|
|
|
|
|
"users"
|
|
|
|
|
where
|
|
|
|
|
"users"."id" = "album_users"."usersId"
|
|
|
|
|
) as obj
|
|
|
|
|
) as "user"
|
|
|
|
|
from
|
|
|
|
|
"albums_shared_users_users" as "album_users"
|
|
|
|
|
where
|
|
|
|
|
"album_users"."albumsId" = "albums"."id"
|
|
|
|
|
) as agg
|
|
|
|
|
) as "albumUsers",
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
to_json(obj)
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
"id",
|
|
|
|
|
"email",
|
|
|
|
|
"createdAt",
|
|
|
|
|
"profileImagePath",
|
|
|
|
|
"isAdmin",
|
|
|
|
|
"shouldChangePassword",
|
|
|
|
|
"deletedAt",
|
|
|
|
|
"oauthId",
|
|
|
|
|
"updatedAt",
|
|
|
|
|
"storageLabel",
|
|
|
|
|
"name",
|
|
|
|
|
"quotaSizeInBytes",
|
|
|
|
|
"quotaUsageInBytes",
|
|
|
|
|
"status",
|
|
|
|
|
"profileChangedAt"
|
|
|
|
|
from
|
|
|
|
|
"users"
|
|
|
|
|
where
|
|
|
|
|
"users"."id" = "albums"."ownerId"
|
|
|
|
|
) as obj
|
|
|
|
|
) as "owner",
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
coalesce(json_agg(agg), '[]')
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
*
|
|
|
|
|
from
|
|
|
|
|
"shared_links"
|
|
|
|
|
where
|
|
|
|
|
"shared_links"."albumId" = "albums"."id"
|
|
|
|
|
) as agg
|
|
|
|
|
) as "sharedLinks"
|
|
|
|
|
from
|
|
|
|
|
"albums"
|
|
|
|
|
left join "albums_shared_users_users" as "shared_albums" on "shared_albums"."albumsId" = "albums"."id"
|
|
|
|
|
left join "shared_links" on "shared_links"."albumId" = "albums"."id"
|
|
|
|
|
where
|
|
|
|
|
"albums"."ownerId" = $1
|
|
|
|
|
and "shared_albums"."usersId" is null
|
|
|
|
|
and "shared_links"."userId" is null
|
|
|
|
|
and "albums"."deletedAt" is null
|
|
|
|
|
order by
|
|
|
|
|
"albums"."createdAt" desc
|
2023-11-30 10:10:30 -05:00
|
|
|
|
|
|
|
|
-- AlbumRepository.getAssetIds
|
2025-01-21 11:24:48 -06:00
|
|
|
select
|
|
|
|
|
*
|
|
|
|
|
from
|
|
|
|
|
"albums_assets_assets"
|
|
|
|
|
where
|
|
|
|
|
"albums_assets_assets"."albumsId" = $1
|
|
|
|
|
and "albums_assets_assets"."assetsId" in ($2)
|