mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-08 23:18:15 -07:00
chore: initial public commit
This commit is contained in:
commit
fc9054b78c
250 changed files with 32809 additions and 0 deletions
45
db/queries/users.sql
Normal file
45
db/queries/users.sql
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
-- name: InsertUser :one
|
||||
INSERT INTO users (username, password, role)
|
||||
VALUES ($1, $2, $3)
|
||||
RETURNING *;
|
||||
|
||||
-- name: DeleteUser :exec
|
||||
DELETE FROM users WHERE id = $1;
|
||||
|
||||
-- name: GetUserByUsername :one
|
||||
SELECT * FROM users WHERE username = $1;
|
||||
|
||||
-- name: CountUsers :one
|
||||
SELECT COUNT(*) FROM users;
|
||||
|
||||
-- name: InsertApiKey :one
|
||||
INSERT INTO api_keys (user_id, key, label)
|
||||
VALUES ($1, $2, $3)
|
||||
RETURNING *;
|
||||
|
||||
-- name: DeleteApiKey :exec
|
||||
DELETE FROM api_keys WHERE id = $1;
|
||||
|
||||
-- name: CountApiKeys :one
|
||||
SELECT COUNT(*) FROM api_keys WHERE user_id = $1;
|
||||
|
||||
-- name: GetUserByApiKey :one
|
||||
SELECT u.*
|
||||
FROM users u
|
||||
JOIN api_keys ak ON u.id = ak.user_id
|
||||
WHERE ak.key = $1;
|
||||
|
||||
-- name: GetAllApiKeysByUserID :many
|
||||
SELECT ak.*
|
||||
FROM api_keys ak
|
||||
JOIN users u ON ak.user_id = u.id
|
||||
WHERE u.id = $1;
|
||||
|
||||
-- name: UpdateUserUsername :exec
|
||||
UPDATE users SET username = $2 WHERE id = $1;
|
||||
|
||||
-- name: UpdateUserPassword :exec
|
||||
UPDATE users SET password = $2 WHERE id = $1;
|
||||
|
||||
-- name: UpdateApiKeyLabel :exec
|
||||
UPDATE api_keys SET label = $3 WHERE id = $1 AND user_id = $2;
|
||||
Loading…
Add table
Add a link
Reference in a new issue