2024-10-23 22:16:51 +02:00
|
|
|
-- 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;
|
|
|
|
|
2024-10-26 21:19:11 +02:00
|
|
|
-- name: GetChirpsByUserid :many
|
|
|
|
SELECT * FROM chirps
|
|
|
|
WHERE chirps.user_id = $1;
|
|
|
|
|
2024-10-23 22:16:51 +02:00
|
|
|
-- name: GetChirp :one
|
|
|
|
SELECT * FROM chirps
|
2024-10-26 15:03:14 +02:00
|
|
|
WHERE chirps.id = $1;
|
|
|
|
|
|
|
|
-- name: DeleteChirp :exec
|
|
|
|
DELETE FROM chirps
|
|
|
|
WHERE id = $1
|
|
|
|
AND user_id = $2;
|