// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.25.0
// source: feeds.sql

package db

import (
	"context"

	"github.com/jackc/pgx/v5/pgtype"
)

const CountFeeds = `-- name: CountFeeds :one
SELECT
    COUNT(*)
FROM
    feeds
`

func (q *Queries) CountFeeds(ctx context.Context) (int64, error) {
	row := q.db.QueryRow(ctx, CountFeeds)
	var count int64
	err := row.Scan(&count)
	return count, err
}

const CreateFeed = `-- name: CreateFeed :one
INSERT INTO
    feeds (
        "url",
        created_at,
        updated_at,
        deleted_at,
        title,
        "description",
        link,
        feed_link,
        links,
        updated,
        updated_parsed,
        published,
        published_parsed,
        "language",
        copyright,
        generator,
        categories,
        custom,
        feed_type,
        feed_version
    )
VALUES
    (
        $1,
        $2,
        $3,
        $4,
        $5,
        $6,
        $7,
        $8,
        $9,
        $10,
        $11,
        $12,
        $13,
        $14,
        $15,
        $16,
        $17,
        $18,
        $19,
        $20
    ) RETURNING id, url, created_at, updated_at, deleted_at, title, description, link, feed_link, links, updated, updated_parsed, published, published_parsed, language, copyright, generator, categories, custom, feed_type, feed_version
`

type CreateFeedParams struct {
	Url             string           `json:"url"`
	CreatedAt       pgtype.Timestamp `json:"created_at"`
	UpdatedAt       pgtype.Timestamp `json:"updated_at"`
	DeletedAt       pgtype.Timestamp `json:"deleted_at"`
	Title           pgtype.Text      `json:"title"`
	Description     pgtype.Text      `json:"description"`
	Link            pgtype.Text      `json:"link"`
	FeedLink        pgtype.Text      `json:"feed_link"`
	Links           []string         `json:"links"`
	Updated         pgtype.Text      `json:"updated"`
	UpdatedParsed   pgtype.Timestamp `json:"updated_parsed"`
	Published       pgtype.Text      `json:"published"`
	PublishedParsed pgtype.Timestamp `json:"published_parsed"`
	Language        pgtype.Text      `json:"language"`
	Copyright       pgtype.Text      `json:"copyright"`
	Generator       pgtype.Text      `json:"generator"`
	Categories      []string         `json:"categories"`
	Custom          []byte           `json:"custom"`
	FeedType        pgtype.Text      `json:"feed_type"`
	FeedVersion     pgtype.Text      `json:"feed_version"`
}

func (q *Queries) CreateFeed(ctx context.Context, arg CreateFeedParams) (Feed, error) {
	row := q.db.QueryRow(ctx, CreateFeed,
		arg.Url,
		arg.CreatedAt,
		arg.UpdatedAt,
		arg.DeletedAt,
		arg.Title,
		arg.Description,
		arg.Link,
		arg.FeedLink,
		arg.Links,
		arg.Updated,
		arg.UpdatedParsed,
		arg.Published,
		arg.PublishedParsed,
		arg.Language,
		arg.Copyright,
		arg.Generator,
		arg.Categories,
		arg.Custom,
		arg.FeedType,
		arg.FeedVersion,
	)
	var i Feed
	err := row.Scan(
		&i.ID,
		&i.Url,
		&i.CreatedAt,
		&i.UpdatedAt,
		&i.DeletedAt,
		&i.Title,
		&i.Description,
		&i.Link,
		&i.FeedLink,
		&i.Links,
		&i.Updated,
		&i.UpdatedParsed,
		&i.Published,
		&i.PublishedParsed,
		&i.Language,
		&i.Copyright,
		&i.Generator,
		&i.Categories,
		&i.Custom,
		&i.FeedType,
		&i.FeedVersion,
	)
	return i, err
}
