-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquery.sql
58 lines (48 loc) · 1008 Bytes
/
query.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
-- name: GetList :one
SELECT * FROM list
WHERE list_id = $1 LIMIT 1;
-- name: CreateList :one
INSERT INTO list (
list_id,
list_name
) VALUES (
gen_random_uuid(),
$1
) RETURNING *;
-- name: DeleteList :exec
DELETE FROM list
WHERE list_id = $1;
-- name: CreateNotification :one
INSERT INTO notifications (
notification_id,
notification_name,
html
) VALUES (
gen_random_uuid(),
$1,
$2
) RETURNING *;
-- name: GetNotification :one
SELECT * FROM notifications
WHERE notification_id = $1 LIMIT 1;
-- name: DeleteNotification :exec
DELETE FROM notifications
WHERE notification_id = $1;
-- name: GetSubscribers :many
SELECT * FROM subscribers
LIMIT $1;
-- name: Unsubscribe :exec
UPDATE subscribers
SET is_subscribed = 'f'
WHERE email = $1;
-- name: GetSubscriber :one
SELECT * FROM subscribers
WHERE subscriber_id = $1;
-- name: CreateSubscriber :one
INSERT INTO subscribers (
subscriber_id,
email
) VALUES (
gen_random_uuid(),
$1
) RETURNING *;