mirror of
https://github.com/immich-app/immich.git
synced 2025-11-13 18:16:51 -05:00
147 lines
3.1 KiB
SQL
147 lines
3.1 KiB
SQL
-- NOTE: This file is auto generated by ./sql-generator
|
|
|
|
-- LibraryRepository.get
|
|
select
|
|
"libraries".*,
|
|
(
|
|
select
|
|
to_json(obj)
|
|
from
|
|
(
|
|
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" = "libraries"."ownerId"
|
|
) as obj
|
|
) as "owner"
|
|
from
|
|
"libraries"
|
|
where
|
|
"libraries"."id" = $1
|
|
and "libraries"."deletedAt" is null
|
|
|
|
-- LibraryRepository.getAll
|
|
select
|
|
"libraries".*,
|
|
(
|
|
select
|
|
to_json(obj)
|
|
from
|
|
(
|
|
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" = "libraries"."ownerId"
|
|
) as obj
|
|
) as "owner"
|
|
from
|
|
"libraries"
|
|
where
|
|
"libraries"."deletedAt" is null
|
|
order by
|
|
"createdAt" asc
|
|
|
|
-- LibraryRepository.getAllDeleted
|
|
select
|
|
"libraries".*,
|
|
(
|
|
select
|
|
to_json(obj)
|
|
from
|
|
(
|
|
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" = "libraries"."ownerId"
|
|
) as obj
|
|
) as "owner"
|
|
from
|
|
"libraries"
|
|
where
|
|
"libraries"."deletedAt" is not null
|
|
order by
|
|
"createdAt" asc
|
|
|
|
-- LibraryRepository.getStatistics
|
|
select
|
|
count(*) filter (
|
|
where
|
|
(
|
|
"assets"."type" = $1
|
|
and "assets"."isVisible" = $2
|
|
)
|
|
) as "photos",
|
|
count(*) filter (
|
|
where
|
|
(
|
|
"assets"."type" = $3
|
|
and "assets"."isVisible" = $4
|
|
)
|
|
) as "videos",
|
|
coalesce(sum("exif"."fileSizeInByte"), $5) as "usage"
|
|
from
|
|
"libraries"
|
|
inner join "assets" on "assets"."libraryId" = "libraries"."id"
|
|
left join "exif" on "exif"."assetId" = "assets"."id"
|
|
where
|
|
"libraries"."id" = $6
|
|
group by
|
|
"libraries"."id"
|
|
select
|
|
0::int as "photos",
|
|
0::int as "videos",
|
|
0::int as "usage",
|
|
0::int as "total"
|
|
from
|
|
"libraries"
|
|
where
|
|
"libraries"."id" = $1
|