You've already forked agentic-coding-workflow
feat(notify): sqlc queries for notifications crud
This commit is contained in:
@@ -1,2 +1,22 @@
|
||||
-- name: Ping :one
|
||||
SELECT 1::int AS ok;
|
||||
-- name: InsertNotification :exec
|
||||
INSERT INTO notifications (id, user_id, topic, severity, title, body, link, metadata, created_at)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9);
|
||||
|
||||
-- name: ListNotificationsByUser :many
|
||||
SELECT id, user_id, topic, severity, title, body, link, metadata, read_at, created_at
|
||||
FROM notifications
|
||||
WHERE user_id = $1
|
||||
AND ($2::bool = false OR read_at IS NULL)
|
||||
ORDER BY created_at DESC
|
||||
LIMIT $3;
|
||||
|
||||
-- name: CountUnreadByUser :one
|
||||
SELECT COUNT(*)::int FROM notifications WHERE user_id = $1 AND read_at IS NULL;
|
||||
|
||||
-- name: MarkRead :exec
|
||||
UPDATE notifications SET read_at = now()
|
||||
WHERE id = $1 AND user_id = $2 AND read_at IS NULL;
|
||||
|
||||
-- name: MarkAllReadByUser :exec
|
||||
UPDATE notifications SET read_at = now()
|
||||
WHERE user_id = $1 AND read_at IS NULL;
|
||||
|
||||
Reference in New Issue
Block a user