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

66 lines
1.1 KiB
MySQL
Raw Normal View History

-- NOTE: This file is auto generated by ./sql-generator
-- LibraryRepository.get
select
2025-07-14 10:13:06 -04:00
"library".*
from
2025-07-14 10:13:06 -04:00
"library"
where
2025-07-14 10:13:06 -04:00
"library"."id" = $1
and "library"."deletedAt" is null
-- LibraryRepository.getAll
select
2025-07-14 10:13:06 -04:00
"library".*
from
2025-07-14 10:13:06 -04:00
"library"
where
2025-07-14 10:13:06 -04:00
"library"."deletedAt" is null
order by
"createdAt" asc
-- LibraryRepository.getAllDeleted
select
2025-07-14 10:13:06 -04:00
"library".*
from
2025-07-14 10:13:06 -04:00
"library"
where
2025-07-14 10:13:06 -04:00
"library"."deletedAt" is not null
order by
"createdAt" asc
-- LibraryRepository.getStatistics
select
2025-01-22 15:17:42 -05:00
count(*) filter (
where
(
2025-07-14 10:13:06 -04:00
"asset"."type" = $1
and "asset"."visibility" != $2
)
) as "photos",
count(*) filter (
where
(
2025-07-14 10:13:06 -04:00
"asset"."type" = $3
and "asset"."visibility" != $4
)
) as "videos",
2025-07-14 10:13:06 -04:00
coalesce(sum("asset_exif"."fileSizeInByte"), $5) as "usage"
from
2025-07-14 10:13:06 -04:00
"library"
inner join "asset" on "asset"."libraryId" = "library"."id"
left join "asset_exif" on "asset_exif"."assetId" = "asset"."id"
where
2025-07-14 10:13:06 -04:00
"library"."id" = $6
group by
2025-07-14 10:13:06 -04:00
"library"."id"
2025-01-22 15:17:42 -05:00
select
0::int as "photos",
0::int as "videos",
0::int as "usage",
0::int as "total"
from
2025-07-14 10:13:06 -04:00
"library"
2025-01-22 15:17:42 -05:00
where
2025-07-14 10:13:06 -04:00
"library"."id" = $1