// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.30.0
// source: reminders.sql

package repository

import (
	"context"

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

const createReminder = `-- name: CreateReminder :one
INSERT INTO event_reminders (id, event_id, minutes_before)
VALUES ($1, $2, $3)
RETURNING id, event_id, minutes_before
`

type CreateReminderParams struct {
	ID            pgtype.UUID `json:"id"`
	EventID       pgtype.UUID `json:"event_id"`
	MinutesBefore int32       `json:"minutes_before"`
}

func (q *Queries) CreateReminder(ctx context.Context, arg CreateReminderParams) (EventReminder, error) {
	row := q.db.QueryRow(ctx, createReminder, arg.ID, arg.EventID, arg.MinutesBefore)
	var i EventReminder
	err := row.Scan(&i.ID, &i.EventID, &i.MinutesBefore)
	return i, err
}

const deleteReminder = `-- name: DeleteReminder :exec
DELETE FROM event_reminders
WHERE id = $1 AND event_id = $2
`

type DeleteReminderParams struct {
	ID      pgtype.UUID `json:"id"`
	EventID pgtype.UUID `json:"event_id"`
}

func (q *Queries) DeleteReminder(ctx context.Context, arg DeleteReminderParams) error {
	_, err := q.db.Exec(ctx, deleteReminder, arg.ID, arg.EventID)
	return err
}

const deleteRemindersByEvent = `-- name: DeleteRemindersByEvent :exec
DELETE FROM event_reminders
WHERE event_id = $1
`

func (q *Queries) DeleteRemindersByEvent(ctx context.Context, eventID pgtype.UUID) error {
	_, err := q.db.Exec(ctx, deleteRemindersByEvent, eventID)
	return err
}

const listRemindersByEvent = `-- name: ListRemindersByEvent :many
SELECT id, event_id, minutes_before
FROM event_reminders
WHERE event_id = $1
ORDER BY minutes_before ASC
`

func (q *Queries) ListRemindersByEvent(ctx context.Context, eventID pgtype.UUID) ([]EventReminder, error) {
	rows, err := q.db.Query(ctx, listRemindersByEvent, eventID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []EventReminder{}
	for rows.Next() {
		var i EventReminder
		if err := rows.Scan(&i.ID, &i.EventID, &i.MinutesBefore); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}
