Adopt sqlc for typed Postgres queries behind store entities.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
-- name: UpsertAnswer :exec
|
||||
INSERT INTO answers (question_id, author_id, body, created_at, updated_at)
|
||||
VALUES ($1, $2, $3, $4, $5)
|
||||
ON CONFLICT (question_id) DO UPDATE
|
||||
SET body = excluded.body, author_id = excluded.author_id, updated_at = excluded.updated_at;
|
||||
|
||||
-- name: GetAnswer :one
|
||||
SELECT a.question_id, a.author_id, u.name AS author_name, a.body, a.created_at, a.updated_at
|
||||
FROM answers a
|
||||
JOIN users u ON u.id = a.author_id
|
||||
WHERE a.question_id = $1;
|
||||
Reference in New Issue
Block a user