22 lines
448 B
SQL
22 lines
448 B
SQL
-- name: CreateChirp :one
|
|
INSERT INTO chirps (id, created_at, updated_at, body, user_id)
|
|
VALUES (
|
|
gen_random_uuid(),
|
|
NOW(),
|
|
NOW(),
|
|
$1,
|
|
$2
|
|
)
|
|
RETURNING *;
|
|
|
|
-- name: GetAllChirps :many
|
|
SELECT id, created_at, updated_at, body, user_id FROM chirps
|
|
ORDER BY created_at ASC;
|
|
|
|
-- name: GetChirpById :one
|
|
SELECT id, created_at, updated_at, body, user_id FROM chirps
|
|
WHERE id = $1;
|
|
|
|
-- name: DeleteChirpById :exec
|
|
DELETE FROM chirps WHERE id = $1;
|