2024-03-04 13:11:06 +00:00
|
|
|
-- name: CountUsers :one
|
|
|
|
SELECT count(*)
|
|
|
|
FROM users;
|
|
|
|
|
|
|
|
-- name: IsAdmin :one
|
|
|
|
SELECT 1
|
|
|
|
FROM users
|
|
|
|
WHERE admin = 1
|
|
|
|
AND token_hash = ?;
|
|
|
|
|
2024-03-04 18:50:13 +00:00
|
|
|
-- name: IsValid :one
|
|
|
|
SELECT 1
|
|
|
|
FROM users
|
|
|
|
WHERE token_hash = ?;
|
|
|
|
|
2024-03-04 13:11:06 +00:00
|
|
|
-- name: GetAllUsers :many
|
2024-03-04 18:50:13 +00:00
|
|
|
SELECT id, name
|
2024-03-04 13:11:06 +00:00
|
|
|
FROM users;
|
|
|
|
|
|
|
|
-- name: CreateUser :execlastid
|
2024-03-04 18:50:13 +00:00
|
|
|
INSERT INTO users (name, admin, token_hash)
|
|
|
|
VALUES (?, ?, ?);
|
|
|
|
|
|
|
|
-- name: RefreshUserToken :exec
|
|
|
|
UPDATE users
|
|
|
|
SET token_hash =?
|
|
|
|
WHERE id = ?
|
|
|
|
AND token_hash = ?;
|
|
|
|
|
|
|
|
-- name: CheckUserDetails :one
|
|
|
|
SELECT 1
|
|
|
|
FROM users
|
|
|
|
WHERE name = ?
|
|
|
|
AND token_hash = ?;
|