UPDATE: Entity, Geo, Wiki
Some checks failed
Build and Release / release (push) Failing after 1m7s

This commit is contained in:
2026-04-22 17:45:09 +07:00
parent f127e2f029
commit adb65d8292
50 changed files with 3354 additions and 119 deletions

56
db/query/wiki.sql Normal file
View File

@@ -0,0 +1,56 @@
-- name: CreateWiki :one
INSERT INTO wikis (
title, content
) VALUES (
$1, $2
)
RETURNING *;
-- name: GetWikiById :one
SELECT *
FROM wikis
WHERE id = $1 AND is_deleted = false;
-- name: UpdateWiki :one
UPDATE wikis
SET
title = COALESCE(sqlc.narg('title'), title),
content = COALESCE(sqlc.narg('content'), content)
WHERE id = sqlc.arg('id') AND is_deleted = false
RETURNING *;
-- name: DeleteWiki :exec
UPDATE wikis
SET
is_deleted = true
WHERE id = $1;
-- name: SearchWikis :many
SELECT w.*
FROM wikis w
WHERE w.is_deleted = false
AND w.title ILIKE '%' || sqlc.arg('title')::text || '%'
AND (
sqlc.narg('entity_id')::uuid IS NULL OR
EXISTS (
SELECT 1
FROM entity_wikis ew
WHERE ew.wiki_id = w.id
AND ew.entity_id = sqlc.narg('entity_id')::uuid
)
)
AND (sqlc.narg('cursor_id')::uuid IS NULL OR w.id < sqlc.narg('cursor_id')::uuid)
ORDER BY w.id DESC
LIMIT sqlc.arg('limit_count');
-- name: BulkDeleteEntityWikisByEntityId :many
DELETE FROM entity_wikis
WHERE entity_id = $1
RETURNING wiki_id;
-- name: CreateEntityWikis :exec
INSERT INTO entity_wikis (
entity_id, wiki_id
)
SELECT $1, unnest(@wiki_ids::uuid[]);