[hw-8] add: repo layer

This commit is contained in:
3ybactuk
2025-07-25 23:04:31 +03:00
committed by 3ybacTuK
parent c1e8934646
commit 6420eaf3d7
25 changed files with 4194 additions and 6 deletions

View File

@@ -0,0 +1,24 @@
-- name: InsertComment :one
INSERT INTO comments (user_id, sku, text) VALUES ($1, $2, $3)
RETURNING id, user_id, sku, text, created_at;
-- name: GetCommentByID :one
SELECT id, user_id, sku, text, created_at FROM comments WHERE id = $1;
-- name: UpdateComment :one
UPDATE comments
SET text = $2
WHERE id = $1
RETURNING id, user_id, sku, text, created_at;
-- name: ListCommentsBySku :many
SELECT id, user_id, sku, text, created_at
FROM comments
WHERE sku = $1
ORDER BY created_at DESC, user_id ASC;
-- name: ListCommentsByUser :many
SELECT id, user_id, sku, text, created_at
FROM comments
WHERE user_id = $1
ORDER BY created_at DESC;