-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquery.sql
50 lines (39 loc) · 1.12 KB
/
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
-- name: GetRoles :many
SELECT id, endpoint, operation, bucket_size, add_token_per_min, initial_tokens, rate_limiter_id FROM role
WHERE deleted_at is NULL and rate_limiter_id = ?;
-- name: CreateRole :one
INSERT INTO role (
endpoint,
operation,
bucket_size,
add_token_per_min,
initial_tokens,
rate_limiter_id
) VALUES (
?, ?, ?, ?, ?, ?
)
RETURNING *;
-- name: DeleteRole :exec
UPDATE role
SET deleted_at = CURRENT_TIMESTAMP
WHERE id = ?;
-- name: GetRateLimiters :many
SELECT * FROM rate_limiter
WHERE deleted_at = null;
-- name: CrateRateLimiter :one
INSERT INTO rate_limiter (
name,
destination
) VALUES (
?,
?
)
RETURNING *;
-- name: DeleteRateLimiter :exec
UPDATE rate_limiter
SET deleted_at = CURRENT_TIMESTAMP
WHERE id = ?;
-- name: GetRole :one
SELECT r.endpoint, r.operation, r.bucket_size, r.add_token_per_min, r.initial_tokens, ra.destination FROM role As r
LEFT JOIN rate_limiter as ra ON ra.id = r.rate_limiter_id
WHERE r.deleted_at is null and r.endpoint = ? and r.operation = ?;