immich/server/src/queries/api.key.repository.sql
2025-02-12 15:23:08 -05:00

59 lines
953 B
SQL

-- NOTE: This file is auto generated by ./sql-generator
-- ApiKeyRepository.getKey
select
"api_keys"."id",
"api_keys"."permissions",
(
select
to_json(obj)
from
(
select
"users"."id",
"users"."name",
"users"."email",
"users"."isAdmin",
"users"."quotaUsageInBytes",
"users"."quotaSizeInBytes"
from
"users"
where
"users"."id" = "api_keys"."userId"
and "users"."deletedAt" is null
) as obj
) as "user"
from
"api_keys"
where
"api_keys"."key" = $1
-- ApiKeyRepository.getById
select
"id",
"name",
"userId",
"createdAt",
"updatedAt",
"permissions"
from
"api_keys"
where
"id" = $1::uuid
and "userId" = $2
-- ApiKeyRepository.getByUserId
select
"id",
"name",
"userId",
"createdAt",
"updatedAt",
"permissions"
from
"api_keys"
where
"userId" = $1
order by
"createdAt" desc