mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
refactor: migrate partner repo to kysely (#15366)
This commit is contained in:
parent
d5a9294eeb
commit
097183b31d
5 changed files with 276 additions and 30 deletions
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue