// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.29.0 // source: feeds.sql package db import ( "context" ) const createFeed = `-- name: CreateFeed :one INSERT INTO feeds (url, title, fetched_at, user_id) VALUES (?, ?, ?, ?) RETURNING id, url, title, fetched_at, is_subscribed, user_id ` type CreateFeedParams struct { Url string Title string FetchedAt string UserID int64 } func (q *Queries) CreateFeed(ctx context.Context, arg CreateFeedParams) (Feed, error) { row := q.db.QueryRowContext(ctx, createFeed, arg.Url, arg.Title, arg.FetchedAt, arg.UserID, ) var i Feed err := row.Scan( &i.ID, &i.Url, &i.Title, &i.FetchedAt, &i.IsSubscribed, &i.UserID, ) return i, err } const deleteFeed = `-- name: DeleteFeed :exec DELETE FROM feeds WHERE id = ? ` func (q *Queries) DeleteFeed(ctx context.Context, id int64) error { _, err := q.db.ExecContext(ctx, deleteFeed, id) return err } const getFeed = `-- name: GetFeed :one SELECT id, url, title, fetched_at, is_subscribed, user_id FROM feeds WHERE id = ? AND user_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, &i.Url, &i.Title, &i.FetchedAt, &i.IsSubscribed, &i.UserID, ) return i, err } const getFeedByURL = `-- name: GetFeedByURL :one SELECT id, url, title, fetched_at, is_subscribed, user_id FROM feeds WHERE url = ? AND user_id = ? ` 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, &i.Url, &i.Title, &i.FetchedAt, &i.IsSubscribed, &i.UserID, ) return i, err } const getFeeds = `-- name: GetFeeds :many SELECT id, url, title, fetched_at, is_subscribed, user_id FROM feeds WHERE is_subscribed = 1 AND user_id = ? ORDER BY id ` 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 } defer rows.Close() items := []Feed{} for rows.Next() { var i Feed if err := rows.Scan( &i.ID, &i.Url, &i.Title, &i.FetchedAt, &i.IsSubscribed, &i.UserID, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const getFeedsToFetch = `-- name: GetFeedsToFetch :many SELECT id, url, fetched_at, user_id FROM feeds WHERE is_subscribed = 1 ` type GetFeedsToFetchRow struct { ID int64 Url string FetchedAt string UserID int64 } func (q *Queries) GetFeedsToFetch(ctx context.Context) ([]GetFeedsToFetchRow, error) { rows, err := q.db.QueryContext(ctx, getFeedsToFetch) if err != nil { return nil, err } defer rows.Close() items := []GetFeedsToFetchRow{} for rows.Next() { var i GetFeedsToFetchRow if err := rows.Scan( &i.ID, &i.Url, &i.FetchedAt, &i.UserID, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const unsubscribeFeed = `-- name: UnsubscribeFeed :exec UPDATE feeds SET is_subscribed = 0 WHERE id = ? ` func (q *Queries) UnsubscribeFeed(ctx context.Context, id int64) error { _, err := q.db.ExecContext(ctx, unsubscribeFeed, id) return err } const updateFeedMetadata = `-- name: UpdateFeedMetadata :exec UPDATE feeds SET title = ?, fetched_at = ? WHERE id = ? ` type UpdateFeedMetadataParams struct { Title string FetchedAt string ID int64 } func (q *Queries) UpdateFeedMetadata(ctx context.Context, arg UpdateFeedMetadataParams) error { _, err := q.db.ExecContext(ctx, updateFeedMetadata, arg.Title, arg.FetchedAt, arg.ID) return err }