chirpy_server/sql/queries/users.sql

31 lines
578 B
MySQL
Raw Normal View History

2024-10-23 22:16:51 +02:00
-- name: CreateUser :one
2024-10-25 23:31:57 +02:00
INSERT INTO users (id, created_at, updated_at, email, hashed_password)
2024-10-23 22:16:51 +02:00
VALUES (
gen_random_uuid(),
NOW(),
NOW(),
2024-10-25 23:31:57 +02:00
$1,
$2
2024-10-23 22:16:51 +02:00
)
RETURNING *;
-- name: DeleteUser :one
DELETE FROM users
RETURNING *;
-- name: GetUserByEmail :one
SELECT * FROM users
2024-10-26 15:03:14 +02:00
WHERE users.email = $1;
-- name: UpgradeUser :exec
UPDATE users
SET is_chirpy_red = true
WHERE id = $1;
-- name: UpdateUserCredentials :one
UPDATE users
SET email = $2,
hashed_password = $3,
updated_at = NOW()
WHERE users.id = $1
RETURNING id, created_at, updated_at, email, is_chirpy_red;