mirror of
https://github.com/immich-app/immich.git
synced 2025-12-21 09:15:44 +03:00
refactor: migrate partner repo to kysely (#15366)
This commit is contained in:
189
server/src/queries/partner.repository.sql
Normal file
189
server/src/queries/partner.repository.sql
Normal file
@@ -0,0 +1,189 @@
|
||||
-- NOTE: This file is auto generated by ./sql-generator
|
||||
|
||||
-- PartnerRepository.getAll
|
||||
select
|
||||
"partners".*,
|
||||
(
|
||||
select
|
||||
to_json(obj)
|
||||
from
|
||||
(
|
||||
select
|
||||
"id",
|
||||
"name",
|
||||
"email",
|
||||
"profileImagePath",
|
||||
"profileChangedAt"
|
||||
from
|
||||
"users" as "sharedBy"
|
||||
where
|
||||
"sharedBy"."id" = "partners"."sharedById"
|
||||
) as obj
|
||||
) as "sharedBy",
|
||||
(
|
||||
select
|
||||
to_json(obj)
|
||||
from
|
||||
(
|
||||
select
|
||||
"id",
|
||||
"name",
|
||||
"email",
|
||||
"profileImagePath",
|
||||
"profileChangedAt"
|
||||
from
|
||||
"users" as "sharedWith"
|
||||
where
|
||||
"sharedWith"."id" = "partners"."sharedWithId"
|
||||
) as obj
|
||||
) as "sharedWith"
|
||||
from
|
||||
"partners"
|
||||
inner join "users" as "sharedBy" on "partners"."sharedById" = "sharedBy"."id"
|
||||
and "sharedBy"."deletedAt" is null
|
||||
inner join "users" as "sharedWith" on "partners"."sharedWithId" = "sharedWith"."id"
|
||||
and "sharedWith"."deletedAt" is null
|
||||
where
|
||||
(
|
||||
"sharedWithId" = $1
|
||||
or "sharedById" = $2
|
||||
)
|
||||
|
||||
-- PartnerRepository.get
|
||||
select
|
||||
"partners".*,
|
||||
(
|
||||
select
|
||||
to_json(obj)
|
||||
from
|
||||
(
|
||||
select
|
||||
"id",
|
||||
"name",
|
||||
"email",
|
||||
"profileImagePath",
|
||||
"profileChangedAt"
|
||||
from
|
||||
"users" as "sharedBy"
|
||||
where
|
||||
"sharedBy"."id" = "partners"."sharedById"
|
||||
) as obj
|
||||
) as "sharedBy",
|
||||
(
|
||||
select
|
||||
to_json(obj)
|
||||
from
|
||||
(
|
||||
select
|
||||
"id",
|
||||
"name",
|
||||
"email",
|
||||
"profileImagePath",
|
||||
"profileChangedAt"
|
||||
from
|
||||
"users" as "sharedWith"
|
||||
where
|
||||
"sharedWith"."id" = "partners"."sharedWithId"
|
||||
) as obj
|
||||
) as "sharedWith"
|
||||
from
|
||||
"partners"
|
||||
inner join "users" as "sharedBy" on "partners"."sharedById" = "sharedBy"."id"
|
||||
and "sharedBy"."deletedAt" is null
|
||||
inner join "users" as "sharedWith" on "partners"."sharedWithId" = "sharedWith"."id"
|
||||
and "sharedWith"."deletedAt" is null
|
||||
where
|
||||
"sharedWithId" = $1
|
||||
and "sharedById" = $2
|
||||
|
||||
-- PartnerRepository.create
|
||||
insert into
|
||||
"partners" ("sharedWithId", "sharedById")
|
||||
values
|
||||
($1, $2)
|
||||
returning
|
||||
*,
|
||||
(
|
||||
select
|
||||
to_json(obj)
|
||||
from
|
||||
(
|
||||
select
|
||||
"id",
|
||||
"name",
|
||||
"email",
|
||||
"profileImagePath",
|
||||
"profileChangedAt"
|
||||
from
|
||||
"users" as "sharedBy"
|
||||
where
|
||||
"sharedBy"."id" = "partners"."sharedById"
|
||||
) as obj
|
||||
) as "sharedBy",
|
||||
(
|
||||
select
|
||||
to_json(obj)
|
||||
from
|
||||
(
|
||||
select
|
||||
"id",
|
||||
"name",
|
||||
"email",
|
||||
"profileImagePath",
|
||||
"profileChangedAt"
|
||||
from
|
||||
"users" as "sharedWith"
|
||||
where
|
||||
"sharedWith"."id" = "partners"."sharedWithId"
|
||||
) as obj
|
||||
) as "sharedWith"
|
||||
|
||||
-- PartnerRepository.update
|
||||
update "partners"
|
||||
set
|
||||
"inTimeline" = $1
|
||||
where
|
||||
"sharedWithId" = $2
|
||||
and "sharedById" = $3
|
||||
returning
|
||||
*,
|
||||
(
|
||||
select
|
||||
to_json(obj)
|
||||
from
|
||||
(
|
||||
select
|
||||
"id",
|
||||
"name",
|
||||
"email",
|
||||
"profileImagePath",
|
||||
"profileChangedAt"
|
||||
from
|
||||
"users" as "sharedBy"
|
||||
where
|
||||
"sharedBy"."id" = "partners"."sharedById"
|
||||
) as obj
|
||||
) as "sharedBy",
|
||||
(
|
||||
select
|
||||
to_json(obj)
|
||||
from
|
||||
(
|
||||
select
|
||||
"id",
|
||||
"name",
|
||||
"email",
|
||||
"profileImagePath",
|
||||
"profileChangedAt"
|
||||
from
|
||||
"users" as "sharedWith"
|
||||
where
|
||||
"sharedWith"."id" = "partners"."sharedWithId"
|
||||
) as obj
|
||||
) as "sharedWith"
|
||||
|
||||
-- PartnerRepository.remove
|
||||
delete from "partners"
|
||||
where
|
||||
"sharedWithId" = $1
|
||||
and "sharedById" = $2
|
||||
Reference in New Issue
Block a user