HN-like selfhosted forums
-- name: GetPost :oneSELECT p.*, u.username as author_usernameFROM posts pJOIN users u ON u.id = p.author_idWHERE p.id = $1;-- name: NewPost :oneINSERT INTO posts(author_id, title, embed_url, body)VALUES ($1, $2, $3, $4)RETURNING *;-- name: GetPostsByUsername :manySELECT p.*, u.username as author_usernameFROM posts pJOIN users u ON u.id = p.author_idWHERE lower(u.username) = lower(sqlc.arg(username)::text)ORDER BY p.created_at DESC;