diff options
Diffstat (limited to 'backend/db/feeds.sql.go')
| -rw-r--r-- | backend/db/feeds.sql.go | 165 |
1 files changed, 165 insertions, 0 deletions
diff --git a/backend/db/feeds.sql.go b/backend/db/feeds.sql.go new file mode 100644 index 0000000..4db84af --- /dev/null +++ b/backend/db/feeds.sql.go @@ -0,0 +1,165 @@ +// 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) +VALUES (?, ?, ?) +RETURNING id, url, title, fetched_at +` + +type CreateFeedParams struct { + Url string + Title string + FetchedAt string +} + +func (q *Queries) CreateFeed(ctx context.Context, arg CreateFeedParams) (Feed, error) { + row := q.db.QueryRowContext(ctx, createFeed, arg.Url, arg.Title, arg.FetchedAt) + var i Feed + err := row.Scan( + &i.ID, + &i.Url, + &i.Title, + &i.FetchedAt, + ) + 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 +FROM feeds +WHERE id = ? +` + +func (q *Queries) GetFeed(ctx context.Context, id int64) (Feed, error) { + row := q.db.QueryRowContext(ctx, getFeed, id) + var i Feed + err := row.Scan( + &i.ID, + &i.Url, + &i.Title, + &i.FetchedAt, + ) + return i, err +} + +const getFeedByURL = `-- name: GetFeedByURL :one +SELECT id, url, title, fetched_at +FROM feeds +WHERE url = ? +` + +func (q *Queries) GetFeedByURL(ctx context.Context, url string) (Feed, error) { + row := q.db.QueryRowContext(ctx, getFeedByURL, url) + var i Feed + err := row.Scan( + &i.ID, + &i.Url, + &i.Title, + &i.FetchedAt, + ) + return i, err +} + +const getFeeds = `-- name: GetFeeds :many +SELECT id, url, title, fetched_at +FROM feeds +ORDER BY id +` + +func (q *Queries) GetFeeds(ctx context.Context) ([]Feed, error) { + rows, err := q.db.QueryContext(ctx, getFeeds) + 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, + ); 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 +FROM feeds +` + +type GetFeedsToFetchRow struct { + ID int64 + Url string + FetchedAt string +} + +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); 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 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 +} |
