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

87 lines
1.5 KiB
MySQL
Raw Normal View History

-- NOTE: This file is auto generated by ./sql-generator
2025-05-15 18:08:31 -04:00
-- SessionRepository.get
select
2025-05-15 18:08:31 -04:00
"id",
"expiresAt",
"pinExpiresAt"
from
2025-07-14 10:13:06 -04:00
"session"
where
2025-05-15 18:08:31 -04:00
"id" = $1
-- SessionRepository.getByToken
select
2025-07-14 10:13:06 -04:00
"session"."id",
"session"."isPendingSyncReset",
"session"."updatedAt",
"session"."pinExpiresAt",
(
select
to_json(obj)
from
(
select
2025-07-14 10:13:06 -04:00
"user"."id",
"user"."name",
"user"."email",
"user"."isAdmin",
"user"."quotaUsageInBytes",
"user"."quotaSizeInBytes"
from
2025-07-14 10:13:06 -04:00
"user"
where
2025-07-14 10:13:06 -04:00
"user"."id" = "session"."userId"
and "user"."deletedAt" is null
) as obj
) as "user"
from
2025-07-14 10:13:06 -04:00
"session"
where
2025-07-14 10:13:06 -04:00
"session"."token" = $1
and (
2025-07-14 10:13:06 -04:00
"session"."expiresAt" is null
or "session"."expiresAt" > $2
)
-- SessionRepository.getByUserId
select
2025-07-14 10:13:06 -04:00
"session".*
from
2025-07-14 10:13:06 -04:00
"session"
inner join "user" on "user"."id" = "session"."userId"
and "user"."deletedAt" is null
where
2025-07-14 10:13:06 -04:00
"session"."userId" = $1
2025-05-15 18:08:31 -04:00
and (
2025-07-14 10:13:06 -04:00
"session"."expiresAt" is null
or "session"."expiresAt" > $2
2025-05-15 18:08:31 -04:00
)
order by
2025-07-14 10:13:06 -04:00
"session"."updatedAt" desc,
"session"."createdAt" desc
-- SessionRepository.delete
2025-07-14 10:13:06 -04:00
delete from "session"
where
"id" = $1::uuid
2025-05-15 18:08:31 -04:00
-- SessionRepository.lockAll
2025-07-14 10:13:06 -04:00
update "session"
2025-05-15 18:08:31 -04:00
set
"pinExpiresAt" = $1
where
"userId" = $2
2025-07-11 09:38:02 -04:00
-- SessionRepository.resetSyncProgress
begin
2025-07-14 10:13:06 -04:00
update "session"
2025-07-11 09:38:02 -04:00
set
"isPendingSyncReset" = $1
where
"id" = $2
2025-07-14 10:13:06 -04:00
delete from "session_sync_checkpoint"
2025-07-11 09:38:02 -04:00
where
"sessionId" = $1
commit