From 6448e973fc62f0e9d162565b09b7e2fa361c46e9 Mon Sep 17 00:00:00 2001 From: Joeyyy09 Date: Thu, 3 Aug 2023 11:44:24 +0530 Subject: [PATCH] Add sql posts --- scraper.go | 2 -- sql/queries/posts.sql | 14 +++++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/scraper.go b/scraper.go index 95c22ea..0dfc29b 100644 --- a/scraper.go +++ b/scraper.go @@ -10,8 +10,6 @@ import ( "strings" "sync" "time" - - "github.com/bootdotdev/projects/posts/internal/database" "github.com/google/uuid" ) diff --git a/sql/queries/posts.sql b/sql/queries/posts.sql index c046fed..9e6ad87 100644 --- a/sql/queries/posts.sql +++ b/sql/queries/posts.sql @@ -1,5 +1,13 @@ -- name: CreatePost :one - -INSERT INTO users (id, created_at, updated_at, title, url, feed_id,published_at,description) +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 *; \ No newline at end of file +RETURNING *; +-- + +-- name: GetPostsForUser :many +SELECT posts.* FROM posts +JOIN feed_follows ON feed_follows.feed_id = posts.feed_id +WHERE feed_follows.user_id = $1 +ORDER BY posts.published_at DESC +LIMIT $2; +-- \ No newline at end of file