feat: added new commands
- added follow command - added unfollow command - following command - introduced logged in user middleware
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
-- name: CreateFollow :one
|
||||
WITH inserted_follow as (
|
||||
INSERT INTO follows (id, created_at, updated_at, feed_id, user_id)
|
||||
VALUES (
|
||||
$1,
|
||||
$2,
|
||||
$3,
|
||||
$4,
|
||||
$5
|
||||
)
|
||||
RETURNING *
|
||||
)
|
||||
SELECT inserted_follow.*,
|
||||
feeds.name as feed_name,
|
||||
users.name as user_name
|
||||
FROM inserted_follow
|
||||
INNER JOIN users
|
||||
ON inserted_follow.user_id = users.id
|
||||
INNER JOIN feeds
|
||||
ON inserted_follow.feed_id = feeds.id;
|
||||
|
||||
-- name: GetFollowsForUser :many
|
||||
SELECT follows.*, feeds.name as feed_name FROM follows
|
||||
INNER JOIN feeds
|
||||
ON follows.feed_id = feeds.id
|
||||
WHERE follows.user_id = $1;
|
||||
|
||||
-- name: DeleteFollowForUser :exec
|
||||
DELETE FROM follows
|
||||
WHERE feed_id = $1 AND user_id = $2;
|
||||
Reference in New Issue
Block a user