Files
chirpy/sql/queries/users.sql
T

34 lines
693 B
SQL
Raw Normal View History

-- name: CreateUser :one
INSERT INTO users (id, created_at, updated_at, email, hashed_password)
VALUES (
gen_random_uuid(),
NOW(),
NOW(),
$1,
$2
)
RETURNING *;
-- name: UpdateUser :one
UPDATE users
SET email = $2, hashed_password = $3, updated_at = NOW()
WHERE id = $1
RETURNING *;
-- name: DeleteAllUsers :exec
DELETE FROM users;
-- name: GetUserById :one
2026-08-15 20:18:21 -05:00
SELECT id, created_at, updated_at, email, hashed_password, is_chirpy_red FROM users
WHERE id = $1;
-- name: GetUserByEmail :one
2026-08-15 20:18:21 -05:00
SELECT id, created_at, updated_at, email, hashed_password, is_chirpy_red FROM users
WHERE email = $1;
2026-08-15 20:18:21 -05:00
-- name: UpgradeUser :one
UPDATE users
SET is_chirpy_red = TRUE
WHERE id = $1
RETURNING *;