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

-- ApiKeyRepository.getKey
select
  "api_key"."id",
  "api_key"."permissions",
  (
    select
      to_json(obj)
    from
      (
        select
          "user"."id",
          "user"."name",
          "user"."email",
          "user"."isAdmin",
          "user"."quotaUsageInBytes",
          "user"."quotaSizeInBytes"
        from
          "user"
        where
          "user"."id" = "api_key"."userId"
          and "user"."deletedAt" is null
      ) as obj
  ) as "user"
from
  "api_key"
where
  "api_key"."key" = $1

-- ApiKeyRepository.getById
select
  "id",
  "name",
  "userId",
  "createdAt",
  "updatedAt",
  "permissions"
from
  "api_key"
where
  "id" = $1::uuid
  and "userId" = $2

-- ApiKeyRepository.getByUserId
select
  "id",
  "name",
  "userId",
  "createdAt",
  "updatedAt",
  "permissions"
from
  "api_key"
where
  "userId" = $1
order by
  "createdAt" desc
