1
0
go-rss-aggregator/internal/database/feed_follows.sql.go
2023-09-09 14:39:32 +03:00

90 lines
1.9 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.21.0
// source: feed_follows.sql
package database
import (
"context"
"time"
)
const createFeedFollow = `-- name: CreateFeedFollow :one
INSERT INTO feed_follows (created_at, updated_at, user_id, feed_id)
VALUES (?, ?, ?, ?)
RETURNING id, created_at, updated_at, user_id, feed_id
`
type CreateFeedFollowParams struct {
CreatedAt time.Time
UpdatedAt time.Time
UserID int64
FeedID int64
}
func (q *Queries) CreateFeedFollow(ctx context.Context, arg CreateFeedFollowParams) (FeedFollow, error) {
row := q.db.QueryRowContext(ctx, createFeedFollow,
arg.CreatedAt,
arg.UpdatedAt,
arg.UserID,
arg.FeedID,
)
var i FeedFollow
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.UserID,
&i.FeedID,
)
return i, err
}
const deleteFeedFollow = `-- name: DeleteFeedFollow :exec
DELETE FROM feed_follows WHERE id = ? AND user_id = ?
`
type DeleteFeedFollowParams struct {
ID int64
UserID int64
}
func (q *Queries) DeleteFeedFollow(ctx context.Context, arg DeleteFeedFollowParams) error {
_, err := q.db.ExecContext(ctx, deleteFeedFollow, arg.ID, arg.UserID)
return err
}
const getFeedFollowsByUser = `-- name: GetFeedFollowsByUser :many
SELECT id, created_at, updated_at, user_id, feed_id FROM feed_follows WHERE user_id = ?
`
func (q *Queries) GetFeedFollowsByUser(ctx context.Context, userID int64) ([]FeedFollow, error) {
rows, err := q.db.QueryContext(ctx, getFeedFollowsByUser, userID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []FeedFollow
for rows.Next() {
var i FeedFollow
if err := rows.Scan(
&i.ID,
&i.CreatedAt,
&i.UpdatedAt,
&i.UserID,
&i.FeedID,
); 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
}