mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
refactor: migrate memory to kysely (#15314)
This commit is contained in:
parent
43b3181f45
commit
93e2545275
5 changed files with 177 additions and 89 deletions
|
|
@ -1,10 +1,79 @@
|
|||
-- NOTE: This file is auto generated by ./sql-generator
|
||||
|
||||
-- MemoryRepository.search
|
||||
select
|
||||
*
|
||||
from
|
||||
"memories"
|
||||
where
|
||||
"ownerId" = $1
|
||||
order by
|
||||
"memoryAt" desc
|
||||
|
||||
-- MemoryRepository.get
|
||||
select
|
||||
"memories".*,
|
||||
(
|
||||
select
|
||||
coalesce(json_agg(agg), '[]')
|
||||
from
|
||||
(
|
||||
select
|
||||
"assets".*
|
||||
from
|
||||
"assets"
|
||||
inner join "memories_assets_assets" on "assets"."id" = "memories_assets_assets"."assetsId"
|
||||
where
|
||||
"memories_assets_assets"."memoriesId" = "memories"."id"
|
||||
and "assets"."deletedAt" is null
|
||||
) as agg
|
||||
) as "assets"
|
||||
from
|
||||
"memories"
|
||||
where
|
||||
"id" = $1
|
||||
and "deletedAt" is null
|
||||
|
||||
-- MemoryRepository.update
|
||||
update "memories"
|
||||
set
|
||||
"ownerId" = $1,
|
||||
"isSaved" = $2
|
||||
where
|
||||
"id" = $3
|
||||
select
|
||||
"memories".*,
|
||||
(
|
||||
select
|
||||
coalesce(json_agg(agg), '[]')
|
||||
from
|
||||
(
|
||||
select
|
||||
"assets".*
|
||||
from
|
||||
"assets"
|
||||
inner join "memories_assets_assets" on "assets"."id" = "memories_assets_assets"."assetsId"
|
||||
where
|
||||
"memories_assets_assets"."memoriesId" = "memories"."id"
|
||||
and "assets"."deletedAt" is null
|
||||
) as agg
|
||||
) as "assets"
|
||||
from
|
||||
"memories"
|
||||
where
|
||||
"id" = $1
|
||||
and "deletedAt" is null
|
||||
|
||||
-- MemoryRepository.delete
|
||||
delete from "memories"
|
||||
where
|
||||
"id" = $1
|
||||
|
||||
-- MemoryRepository.getAssetIds
|
||||
SELECT
|
||||
"memories_assets"."assetsId" AS "assetId"
|
||||
FROM
|
||||
"memories_assets_assets" "memories_assets"
|
||||
WHERE
|
||||
"memories_assets"."memoriesId" = $1
|
||||
AND "memories_assets"."assetsId" IN ($2)
|
||||
select
|
||||
"assetsId"
|
||||
from
|
||||
"memories_assets_assets"
|
||||
where
|
||||
"memoriesId" = $1
|
||||
and "assetsId" in ($2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue