Skip to content

High performance self-hosted photo and video management solution.

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

-- OcrRepository.getById
select
  "asset_ocr".*
from
  "asset_ocr"
where
  "asset_ocr"."id" = $1

-- OcrRepository.getByAssetId
select
  "asset_ocr".*
from
  "asset_ocr"
where
  "asset_ocr"."assetId" = $1
  and "asset_ocr"."isVisible" = $2

-- OcrRepository.upsert
with
  "deleted_ocr" as (
    delete from "asset_ocr"
    where
      "assetId" = $1
  ),
  "inserted_ocr" as (
    insert into
      "asset_ocr" (
        "assetId",
        "x1",
        "y1",
        "x2",
        "y2",
        "x3",
        "y3",
        "x4",
        "y4",
        "text",
        "boxScore",
        "textScore"
      )
    values
      (
        $2,
        $3,
        $4,
        $5,
        $6,
        $7,
        $8,
        $9,
        $10,
        $11,
        $12,
        $13
      )
  ),
  "inserted_search" as (
    insert into
      "ocr_search" ("assetId", "text")
    values
      ($14, $15)
    on conflict ("assetId") do update
    set
      "text" = "excluded"."text"
  )
select
  1 as "dummy"

-- OcrRepository.updateOcrVisibilities
begin
update "ocr_search"
set
  "text" = $1
where
  "assetId" = $2
commit