Skip to content

High performance self-hosted photo and video management solution.

1.7 KB
Raw Blame
-- NOTE: This file is auto generated by ./sql-generator

-- SessionRepository.get
select
  "id",
  "expiresAt",
  "pinExpiresAt",
  "oauthBearerToken"
from
  "session"
where
  "id" = $1

-- SessionRepository.isPendingSyncReset
select
  "isPendingSyncReset"
from
  "session"
where
  "id" = $1

-- SessionRepository.getByToken
select
  "session"."id",
  "session"."updatedAt",
  "session"."pinExpiresAt",
  "session"."appVersion",
  (
    select
      to_json(obj)
    from
      (
        select
          "user"."id",
          "user"."name",
          "user"."email",
          "user"."isAdmin",
          "user"."quotaUsageInBytes",
          "user"."quotaSizeInBytes"
        from
          "user"
        where
          "user"."id" = "session"."userId"
          and "user"."deletedAt" is null
      ) as obj
  ) as "user"
from
  "session"
where
  "session"."token" = $1
  and (
    "session"."expiresAt" is null
    or "session"."expiresAt" > $2
  )

-- SessionRepository.getByUserId
select
  "session".*
from
  "session"
  inner join "user" on "user"."id" = "session"."userId"
  and "user"."deletedAt" is null
where
  "session"."userId" = $1
  and (
    "session"."expiresAt" is null
    or "session"."expiresAt" > $2
  )
order by
  "session"."updatedAt" desc,
  "session"."createdAt" desc

-- SessionRepository.delete
delete from "session"
where
  "id" = $1::uuid

-- SessionRepository.invalidateAll
delete from "session"
where
  "userId" = $1
  and "id" != $2

-- SessionRepository.lockAll
update "session"
set
  "pinExpiresAt" = $1
where
  "userId" = $2

-- SessionRepository.resetSyncProgress
begin
update "session"
set
  "isPendingSyncReset" = $1
where
  "id" = $2
delete from "session_sync_checkpoint"
where
  "sessionId" = $1
commit