// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.29.0 // source: articles.sql package db import ( "context" ) const checkArticleExists = `-- name: CheckArticleExists :one SELECT EXISTS( SELECT 1 FROM articles WHERE feed_id = ? AND guid = ? ) as article_exists ` type CheckArticleExistsParams struct { FeedID int64 Guid string } func (q *Queries) CheckArticleExists(ctx context.Context, arg CheckArticleExistsParams) (int64, error) { row := q.db.QueryRowContext(ctx, checkArticleExists, arg.FeedID, arg.Guid) var article_exists int64 err := row.Scan(&article_exists) return article_exists, err } const checkArticleExistsByGUID = `-- name: CheckArticleExistsByGUID :one SELECT EXISTS( SELECT 1 FROM articles WHERE guid = ? ) as article_exists ` func (q *Queries) CheckArticleExistsByGUID(ctx context.Context, guid string) (int64, error) { row := q.db.QueryRowContext(ctx, checkArticleExistsByGUID, guid) var article_exists int64 err := row.Scan(&article_exists) return article_exists, err } const createArticle = `-- name: CreateArticle :one INSERT INTO articles (feed_id, guid, title, url, is_read) VALUES (?, ?, ?, ?, ?) RETURNING id, feed_id, guid, title, url, is_read ` type CreateArticleParams struct { FeedID int64 Guid string Title string Url string IsRead int64 } func (q *Queries) CreateArticle(ctx context.Context, arg CreateArticleParams) (Article, error) { row := q.db.QueryRowContext(ctx, createArticle, arg.FeedID, arg.Guid, arg.Title, arg.Url, arg.IsRead, ) var i Article err := row.Scan( &i.ID, &i.FeedID, &i.Guid, &i.Title, &i.Url, &i.IsRead, ) return i, err } const deleteArticlesByFeed = `-- name: DeleteArticlesByFeed :exec DELETE FROM articles WHERE feed_id = ? ` func (q *Queries) DeleteArticlesByFeed(ctx context.Context, feedID int64) error { _, err := q.db.ExecContext(ctx, deleteArticlesByFeed, feedID) return err } const getArticle = `-- name: GetArticle :one SELECT a.id, a.feed_id, a.guid, a.title, a.url, a.is_read, f.id as feed_id_2, f.url as feed_url, f.title as feed_title, f.is_subscribed as feed_is_subscribed FROM articles AS a INNER JOIN feeds AS f ON a.feed_id = f.id WHERE a.id = ? ` type GetArticleRow struct { ID int64 FeedID int64 Guid string Title string Url string IsRead int64 FeedID2 int64 FeedUrl string FeedTitle string FeedIsSubscribed int64 } func (q *Queries) GetArticle(ctx context.Context, id int64) (GetArticleRow, error) { row := q.db.QueryRowContext(ctx, getArticle, id) var i GetArticleRow err := row.Scan( &i.ID, &i.FeedID, &i.Guid, &i.Title, &i.Url, &i.IsRead, &i.FeedID2, &i.FeedUrl, &i.FeedTitle, &i.FeedIsSubscribed, ) return i, err } const getArticleGUIDsByFeed = `-- name: GetArticleGUIDsByFeed :many SELECT guid FROM articles WHERE feed_id = ? ` func (q *Queries) GetArticleGUIDsByFeed(ctx context.Context, feedID int64) ([]string, error) { rows, err := q.db.QueryContext(ctx, getArticleGUIDsByFeed, feedID) if err != nil { return nil, err } defer rows.Close() items := []string{} for rows.Next() { var guid string if err := rows.Scan(&guid); err != nil { return nil, err } items = append(items, guid) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const getArticlesByFeed = `-- name: GetArticlesByFeed :many SELECT id, feed_id, guid, title, url, is_read FROM articles WHERE feed_id = ? ORDER BY id DESC ` func (q *Queries) GetArticlesByFeed(ctx context.Context, feedID int64) ([]Article, error) { rows, err := q.db.QueryContext(ctx, getArticlesByFeed, feedID) if err != nil { return nil, err } defer rows.Close() items := []Article{} for rows.Next() { var i Article if err := rows.Scan( &i.ID, &i.FeedID, &i.Guid, &i.Title, &i.Url, &i.IsRead, ); 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 getArticlesByFeedPaginated = `-- name: GetArticlesByFeedPaginated :many SELECT a.id, a.feed_id, a.guid, a.title, a.url, a.is_read, f.id as feed_id_2, f.url as feed_url, f.title as feed_title, f.is_subscribed as feed_is_subscribed FROM articles AS a INNER JOIN feeds AS f ON a.feed_id = f.id WHERE a.is_read = ? AND f.is_subscribed = 1 AND f.user_id = ? AND a.feed_id = ? ORDER BY a.id DESC LIMIT ? ` type GetArticlesByFeedPaginatedParams struct { IsRead int64 UserID int64 FeedID int64 Limit int64 } type GetArticlesByFeedPaginatedRow struct { ID int64 FeedID int64 Guid string Title string Url string IsRead int64 FeedID2 int64 FeedUrl string FeedTitle string FeedIsSubscribed int64 } func (q *Queries) GetArticlesByFeedPaginated(ctx context.Context, arg GetArticlesByFeedPaginatedParams) ([]GetArticlesByFeedPaginatedRow, error) { rows, err := q.db.QueryContext(ctx, getArticlesByFeedPaginated, arg.IsRead, arg.UserID, arg.FeedID, arg.Limit, ) if err != nil { return nil, err } defer rows.Close() items := []GetArticlesByFeedPaginatedRow{} for rows.Next() { var i GetArticlesByFeedPaginatedRow if err := rows.Scan( &i.ID, &i.FeedID, &i.Guid, &i.Title, &i.Url, &i.IsRead, &i.FeedID2, &i.FeedUrl, &i.FeedTitle, &i.FeedIsSubscribed, ); 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 getArticlesByFeedPaginatedAfter = `-- name: GetArticlesByFeedPaginatedAfter :many SELECT a.id, a.feed_id, a.guid, a.title, a.url, a.is_read, f.id as feed_id_2, f.url as feed_url, f.title as feed_title, f.is_subscribed as feed_is_subscribed FROM articles AS a INNER JOIN feeds AS f ON a.feed_id = f.id WHERE a.is_read = ? AND f.is_subscribed = 1 AND f.user_id = ? AND a.feed_id = ? AND a.id < ? ORDER BY a.id DESC LIMIT ? ` type GetArticlesByFeedPaginatedAfterParams struct { IsRead int64 UserID int64 FeedID int64 ID int64 Limit int64 } type GetArticlesByFeedPaginatedAfterRow struct { ID int64 FeedID int64 Guid string Title string Url string IsRead int64 FeedID2 int64 FeedUrl string FeedTitle string FeedIsSubscribed int64 } func (q *Queries) GetArticlesByFeedPaginatedAfter(ctx context.Context, arg GetArticlesByFeedPaginatedAfterParams) ([]GetArticlesByFeedPaginatedAfterRow, error) { rows, err := q.db.QueryContext(ctx, getArticlesByFeedPaginatedAfter, arg.IsRead, arg.UserID, arg.FeedID, arg.ID, arg.Limit, ) if err != nil { return nil, err } defer rows.Close() items := []GetArticlesByFeedPaginatedAfterRow{} for rows.Next() { var i GetArticlesByFeedPaginatedAfterRow if err := rows.Scan( &i.ID, &i.FeedID, &i.Guid, &i.Title, &i.Url, &i.IsRead, &i.FeedID2, &i.FeedUrl, &i.FeedTitle, &i.FeedIsSubscribed, ); 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 getArticlesPaginated = `-- name: GetArticlesPaginated :many SELECT a.id, a.feed_id, a.guid, a.title, a.url, a.is_read, f.id as feed_id_2, f.url as feed_url, f.title as feed_title, f.is_subscribed as feed_is_subscribed FROM articles AS a INNER JOIN feeds AS f ON a.feed_id = f.id WHERE a.is_read = ? AND f.is_subscribed = 1 AND f.user_id = ? ORDER BY a.id DESC LIMIT ? ` type GetArticlesPaginatedParams struct { IsRead int64 UserID int64 Limit int64 } type GetArticlesPaginatedRow struct { ID int64 FeedID int64 Guid string Title string Url string IsRead int64 FeedID2 int64 FeedUrl string FeedTitle string FeedIsSubscribed int64 } func (q *Queries) GetArticlesPaginated(ctx context.Context, arg GetArticlesPaginatedParams) ([]GetArticlesPaginatedRow, error) { rows, err := q.db.QueryContext(ctx, getArticlesPaginated, arg.IsRead, arg.UserID, arg.Limit) if err != nil { return nil, err } defer rows.Close() items := []GetArticlesPaginatedRow{} for rows.Next() { var i GetArticlesPaginatedRow if err := rows.Scan( &i.ID, &i.FeedID, &i.Guid, &i.Title, &i.Url, &i.IsRead, &i.FeedID2, &i.FeedUrl, &i.FeedTitle, &i.FeedIsSubscribed, ); 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 getArticlesPaginatedAfter = `-- name: GetArticlesPaginatedAfter :many SELECT a.id, a.feed_id, a.guid, a.title, a.url, a.is_read, f.id as feed_id_2, f.url as feed_url, f.title as feed_title, f.is_subscribed as feed_is_subscribed FROM articles AS a INNER JOIN feeds AS f ON a.feed_id = f.id WHERE a.is_read = ? AND f.is_subscribed = 1 AND f.user_id = ? AND a.id < ? ORDER BY a.id DESC LIMIT ? ` type GetArticlesPaginatedAfterParams struct { IsRead int64 UserID int64 ID int64 Limit int64 } type GetArticlesPaginatedAfterRow struct { ID int64 FeedID int64 Guid string Title string Url string IsRead int64 FeedID2 int64 FeedUrl string FeedTitle string FeedIsSubscribed int64 } func (q *Queries) GetArticlesPaginatedAfter(ctx context.Context, arg GetArticlesPaginatedAfterParams) ([]GetArticlesPaginatedAfterRow, error) { rows, err := q.db.QueryContext(ctx, getArticlesPaginatedAfter, arg.IsRead, arg.UserID, arg.ID, arg.Limit, ) if err != nil { return nil, err } defer rows.Close() items := []GetArticlesPaginatedAfterRow{} for rows.Next() { var i GetArticlesPaginatedAfterRow if err := rows.Scan( &i.ID, &i.FeedID, &i.Guid, &i.Title, &i.Url, &i.IsRead, &i.FeedID2, &i.FeedUrl, &i.FeedTitle, &i.FeedIsSubscribed, ); 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 markFeedArticlesRead = `-- name: MarkFeedArticlesRead :exec UPDATE articles SET is_read = 1 WHERE feed_id = ? ` func (q *Queries) MarkFeedArticlesRead(ctx context.Context, feedID int64) error { _, err := q.db.ExecContext(ctx, markFeedArticlesRead, feedID) return err } const markFeedArticlesUnread = `-- name: MarkFeedArticlesUnread :exec UPDATE articles SET is_read = 0 WHERE feed_id = ? ` func (q *Queries) MarkFeedArticlesUnread(ctx context.Context, feedID int64) error { _, err := q.db.ExecContext(ctx, markFeedArticlesUnread, feedID) return err } const updateArticle = `-- name: UpdateArticle :exec UPDATE articles SET title = ?, url = ? WHERE feed_id = ? AND guid = ? ` type UpdateArticleParams struct { Title string Url string FeedID int64 Guid string } func (q *Queries) UpdateArticle(ctx context.Context, arg UpdateArticleParams) error { _, err := q.db.ExecContext(ctx, updateArticle, arg.Title, arg.Url, arg.FeedID, arg.Guid, ) return err } const updateArticleReadStatus = `-- name: UpdateArticleReadStatus :exec UPDATE articles SET is_read = ? WHERE id = ? ` type UpdateArticleReadStatusParams struct { IsRead int64 ID int64 } func (q *Queries) UpdateArticleReadStatus(ctx context.Context, arg UpdateArticleReadStatusParams) error { _, err := q.db.ExecContext(ctx, updateArticleReadStatus, arg.IsRead, arg.ID) return err }