-- NOTE: This file is auto generated by ./sql-generator

-- LibraryRepository.get
select
  "library".*
from
  "library"
where
  "library"."id" = $1
  and "library"."deletedAt" is null

-- LibraryRepository.getAll
select
  "library".*
from
  "library"
where
  "library"."deletedAt" is null
order by
  "createdAt" asc

-- LibraryRepository.getAllDeleted
select
  "library".*
from
  "library"
where
  "library"."deletedAt" is not null
order by
  "createdAt" asc

-- LibraryRepository.getStatistics
select
  count(*) filter (
    where
      (
        "asset"."type" = $1
        and "asset"."visibility" != $2
        and "asset"."isOffline" = $3
      )
  ) as "photos",
  count(*) filter (
    where
      (
        "asset"."type" = $4
        and "asset"."visibility" != $5
        and "asset"."isOffline" = $6
      )
  ) as "videos",
  count(*) filter (
    where
      (
        "asset"."isOffline" = $7
        and "asset"."visibility" != $8
      )
  ) as "offline",
  coalesce(sum("asset_exif"."fileSizeInByte"), $9) as "usage"
from
  "library"
  inner join "asset" on "asset"."libraryId" = "library"."id"
  left join "asset_exif" on "asset_exif"."assetId" = "asset"."id"
where
  "library"."id" = $10
group by
  "library"."id"
select
  0::int as "photos",
  0::int as "videos",
  0::int as "offline",
  0::int as "usage",
  0::int as "total"
from
  "library"
where
  "library"."id" = $1
