aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/query.sql
diff options
context:
space:
mode:
Diffstat (limited to 'backend/query.sql')
-rw-r--r--backend/query.sql15
1 files changed, 15 insertions, 0 deletions
diff --git a/backend/query.sql b/backend/query.sql
index f0e4034..13bbbe6 100644
--- a/backend/query.sql
+++ b/backend/query.sql
@@ -3,6 +3,11 @@ SELECT * FROM users
WHERE users.user_id = $1
LIMIT 1;
+-- name: CreateUser :one
+INSERT INTO users (username, display_name, is_admin)
+VALUES ($1, $1, false)
+RETURNING user_id;
+
-- name: ListUsers :many
SELECT * FROM users
ORDER BY users.user_id;
@@ -13,6 +18,16 @@ JOIN user_auths ON users.user_id = user_auths.user_id
WHERE users.username = $1
LIMIT 1;
+-- name: CreateUserAuth :exec
+INSERT INTO user_auths (user_id, auth_type)
+VALUES ($1, $2);
+
+-- name: IsRegistrationTokenValid :one
+SELECT EXISTS (
+ SELECT 1 FROM registration_tokens
+ WHERE token = $1
+);
+
-- name: ListGames :many
SELECT * FROM games
LEFT JOIN problems ON games.problem_id = problems.problem_id