feat: Added chapter 8

This commit is contained in:
2024-10-26 15:03:14 +02:00
parent 61beecd4a0
commit 8b7fdf59b5
13 changed files with 289 additions and 5 deletions

View File

@ -15,4 +15,9 @@ ORDER BY created_at ASC;
-- name: GetChirp :one
SELECT * FROM chirps
WHERE chirps.id = $1;
WHERE chirps.id = $1;
-- name: DeleteChirp :exec
DELETE FROM chirps
WHERE id = $1
AND user_id = $2;

View File

@ -0,0 +1,7 @@
-- 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;

View File

@ -15,4 +15,9 @@ RETURNING *;
-- name: GetUserByEmail :one
SELECT * FROM users
WHERE users.email = $1;
WHERE users.email = $1;
-- name: UpgradeUser :exec
UPDATE users
SET is_chirpy_red = true
WHERE id = $1;