Files
goyomi/internal/db/queries/source.sql
T
2026-05-11 06:48:23 +00:00

25 lines
630 B
SQL
Executable File

-- name: UpsertSource :one
INSERT INTO sources (id, name, lang, is_nsfw)
VALUES ($1, $2, $3, $4)
ON CONFLICT (id) DO UPDATE
SET name = EXCLUDED.name,
lang = EXCLUDED.lang,
is_nsfw = EXCLUDED.is_nsfw
RETURNING *;
-- name: ListSources :many
SELECT * FROM sources ORDER BY id;
-- name: GetSourceByID :one
SELECT * FROM sources WHERE id = $1;
-- name: GetSourceMeta :one
SELECT value FROM source_meta
WHERE source_id = $1 AND key = $2;
-- name: SetSourceMeta :exec
INSERT INTO source_meta (source_id, key, value)
VALUES ($1, $2, $3)
ON CONFLICT (source_id, key) DO UPDATE
SET value = EXCLUDED.value;