feat: Added chapter 5

This commit is contained in:
2024-10-23 22:16:51 +02:00
parent 141e1df0cb
commit 9603509fcd
16 changed files with 471 additions and 8 deletions

18
sql/queries/chirps.sql Normal file
View File

@ -0,0 +1,18 @@
-- name: CreateChirp :one
INSERT INTO chirps (id, created_at, updated_at, body, user_id)
VALUES (
gen_random_uuid(),
NOW(),
NOW(),
$1,
$2
)
RETURNING *;
-- name: GetChirps :many
SELECT * FROM chirps
ORDER BY created_at ASC;
-- name: GetChirp :one
SELECT * FROM chirps
WHERE chirps.id = $1;

13
sql/queries/users.sql Normal file
View File

@ -0,0 +1,13 @@
-- name: CreateUser :one
INSERT INTO users (id, created_at, updated_at, email)
VALUES (
gen_random_uuid(),
NOW(),
NOW(),
$1
)
RETURNING *;
-- name: DeleteUser :one
DELETE FROM users
RETURNING *;