34 lines
605 B
SQL
34 lines
605 B
SQL
-- name: CreatePost :one
|
|
INSERT INTO posts (id, created_at, updated_at, title, url, description, published_at, feed_id)
|
|
VALUES (
|
|
$1,
|
|
$2,
|
|
$3,
|
|
$4,
|
|
$5,
|
|
$6,
|
|
$7,
|
|
$8
|
|
)
|
|
RETURNING *;
|
|
|
|
-- name: GetPostsForUser :many
|
|
SELECT
|
|
posts.id,
|
|
posts.created_at,
|
|
posts.updated_at,
|
|
posts.title,
|
|
posts.url,
|
|
posts.description,
|
|
posts.published_at,
|
|
posts.feed_id,
|
|
feeds.name as feed_name
|
|
FROM posts
|
|
INNER JOIN feeds
|
|
ON posts.feed_id = feeds.id
|
|
INNER JOIN follows
|
|
ON posts.feed_id = follows.feed_id
|
|
WHERE follows.user_id = $1
|
|
ORDER BY posts.published_at DESC, posts.title ASC
|
|
LIMIT $2;
|