diff options
Diffstat (limited to 'backend/db/feeds.sql.go')
| -rw-r--r-- | backend/db/feeds.sql.go | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/backend/db/feeds.sql.go b/backend/db/feeds.sql.go index 140fa3a..5a9b6b9 100644 --- a/backend/db/feeds.sql.go +++ b/backend/db/feeds.sql.go @@ -54,11 +54,16 @@ func (q *Queries) DeleteFeed(ctx context.Context, id int64) error { const getFeed = `-- name: GetFeed :one SELECT id, url, title, fetched_at, is_subscribed, user_id FROM feeds -WHERE id = ? +WHERE id = ? AND user_id = ? ` -func (q *Queries) GetFeed(ctx context.Context, id int64) (Feed, error) { - row := q.db.QueryRowContext(ctx, getFeed, id) +type GetFeedParams struct { + ID int64 + UserID int64 +} + +func (q *Queries) GetFeed(ctx context.Context, arg GetFeedParams) (Feed, error) { + row := q.db.QueryRowContext(ctx, getFeed, arg.ID, arg.UserID) var i Feed err := row.Scan( &i.ID, @@ -74,11 +79,16 @@ func (q *Queries) GetFeed(ctx context.Context, id int64) (Feed, error) { const getFeedByURL = `-- name: GetFeedByURL :one SELECT id, url, title, fetched_at, is_subscribed, user_id FROM feeds -WHERE url = ? +WHERE url = ? AND user_id = ? ` -func (q *Queries) GetFeedByURL(ctx context.Context, url string) (Feed, error) { - row := q.db.QueryRowContext(ctx, getFeedByURL, url) +type GetFeedByURLParams struct { + Url string + UserID int64 +} + +func (q *Queries) GetFeedByURL(ctx context.Context, arg GetFeedByURLParams) (Feed, error) { + row := q.db.QueryRowContext(ctx, getFeedByURL, arg.Url, arg.UserID) var i Feed err := row.Scan( &i.ID, @@ -94,12 +104,12 @@ func (q *Queries) GetFeedByURL(ctx context.Context, url string) (Feed, error) { const getFeeds = `-- name: GetFeeds :many SELECT id, url, title, fetched_at, is_subscribed, user_id FROM feeds -WHERE is_subscribed = 1 +WHERE is_subscribed = 1 AND user_id = ? ORDER BY id ` -func (q *Queries) GetFeeds(ctx context.Context) ([]Feed, error) { - rows, err := q.db.QueryContext(ctx, getFeeds) +func (q *Queries) GetFeeds(ctx context.Context, userID int64) ([]Feed, error) { + rows, err := q.db.QueryContext(ctx, getFeeds, userID) if err != nil { return nil, err } |
