e7022124be
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
777 lines
17 KiB
Go
777 lines
17 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: queries.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"time"
|
|
)
|
|
|
|
const countClaimsBySlot = `-- name: CountClaimsBySlot :one
|
|
SELECT COUNT(*) FROM claims WHERE slot_id = ?
|
|
`
|
|
|
|
func (q *Queries) CountClaimsBySlot(ctx context.Context, slotID int64) (int64, error) {
|
|
row := q.db.QueryRowContext(ctx, countClaimsBySlot, slotID)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const countRsvps = `-- name: CountRsvps :one
|
|
SELECT COUNT(*) FROM rsvps WHERE event_id = ?
|
|
`
|
|
|
|
func (q *Queries) CountRsvps(ctx context.Context, eventID int64) (int64, error) {
|
|
row := q.db.QueryRowContext(ctx, countRsvps, eventID)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const createClaim = `-- name: CreateClaim :one
|
|
INSERT INTO claims (slot_id, name, note)
|
|
VALUES (?, ?, ?)
|
|
RETURNING id, slot_id, name, note, created_at
|
|
`
|
|
|
|
type CreateClaimParams struct {
|
|
SlotID int64
|
|
Name string
|
|
Note string
|
|
}
|
|
|
|
func (q *Queries) CreateClaim(ctx context.Context, arg CreateClaimParams) (Claim, error) {
|
|
row := q.db.QueryRowContext(ctx, createClaim, arg.SlotID, arg.Name, arg.Note)
|
|
var i Claim
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.SlotID,
|
|
&i.Name,
|
|
&i.Note,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const createEvent = `-- name: CreateEvent :one
|
|
INSERT INTO events (slug, title, date, time, location, admin_token, description)
|
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
RETURNING id, slug, title, date, time, location, admin_token, description, user_id, created_at
|
|
`
|
|
|
|
type CreateEventParams struct {
|
|
Slug string
|
|
Title string
|
|
Date string
|
|
Time string
|
|
Location string
|
|
AdminToken string
|
|
Description string
|
|
}
|
|
|
|
func (q *Queries) CreateEvent(ctx context.Context, arg CreateEventParams) (Event, error) {
|
|
row := q.db.QueryRowContext(ctx, createEvent,
|
|
arg.Slug,
|
|
arg.Title,
|
|
arg.Date,
|
|
arg.Time,
|
|
arg.Location,
|
|
arg.AdminToken,
|
|
arg.Description,
|
|
)
|
|
var i Event
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Slug,
|
|
&i.Title,
|
|
&i.Date,
|
|
&i.Time,
|
|
&i.Location,
|
|
&i.AdminToken,
|
|
&i.Description,
|
|
&i.UserID,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const createRsvp = `-- name: CreateRsvp :one
|
|
INSERT INTO rsvps (event_id, name, note, plus_one)
|
|
VALUES (?, ?, ?, ?)
|
|
RETURNING id, event_id, name, note, plus_one, created_at
|
|
`
|
|
|
|
type CreateRsvpParams struct {
|
|
EventID int64
|
|
Name string
|
|
Note string
|
|
PlusOne int64
|
|
}
|
|
|
|
func (q *Queries) CreateRsvp(ctx context.Context, arg CreateRsvpParams) (Rsvp, error) {
|
|
row := q.db.QueryRowContext(ctx, createRsvp,
|
|
arg.EventID,
|
|
arg.Name,
|
|
arg.Note,
|
|
arg.PlusOne,
|
|
)
|
|
var i Rsvp
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.EventID,
|
|
&i.Name,
|
|
&i.Note,
|
|
&i.PlusOne,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const createSession = `-- name: CreateSession :exec
|
|
INSERT INTO sessions (token, user_id, expires_at) VALUES (?, ?, ?)
|
|
`
|
|
|
|
type CreateSessionParams struct {
|
|
Token string
|
|
UserID int64
|
|
ExpiresAt time.Time
|
|
}
|
|
|
|
func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) error {
|
|
_, err := q.db.ExecContext(ctx, createSession, arg.Token, arg.UserID, arg.ExpiresAt)
|
|
return err
|
|
}
|
|
|
|
const createSlot = `-- name: CreateSlot :one
|
|
INSERT INTO slots (event_id, name, emoji, max_claims, sort_order)
|
|
VALUES (?, ?, ?, ?, ?)
|
|
RETURNING id, event_id, name, emoji, max_claims, sort_order
|
|
`
|
|
|
|
type CreateSlotParams struct {
|
|
EventID int64
|
|
Name string
|
|
Emoji string
|
|
MaxClaims int64
|
|
SortOrder int64
|
|
}
|
|
|
|
func (q *Queries) CreateSlot(ctx context.Context, arg CreateSlotParams) (Slot, error) {
|
|
row := q.db.QueryRowContext(ctx, createSlot,
|
|
arg.EventID,
|
|
arg.Name,
|
|
arg.Emoji,
|
|
arg.MaxClaims,
|
|
arg.SortOrder,
|
|
)
|
|
var i Slot
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.EventID,
|
|
&i.Name,
|
|
&i.Emoji,
|
|
&i.MaxClaims,
|
|
&i.SortOrder,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const createUserByEmail = `-- name: CreateUserByEmail :one
|
|
INSERT INTO users (email, name) VALUES (?, '') RETURNING id, phone, email, name, created_at
|
|
`
|
|
|
|
func (q *Queries) CreateUserByEmail(ctx context.Context, email sql.NullString) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, createUserByEmail, email)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Phone,
|
|
&i.Email,
|
|
&i.Name,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const createUserByPhone = `-- name: CreateUserByPhone :one
|
|
INSERT INTO users (phone, name) VALUES (?, '') RETURNING id, phone, email, name, created_at
|
|
`
|
|
|
|
func (q *Queries) CreateUserByPhone(ctx context.Context, phone sql.NullString) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, createUserByPhone, phone)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Phone,
|
|
&i.Email,
|
|
&i.Name,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const createVerificationCode = `-- name: CreateVerificationCode :exec
|
|
INSERT INTO verification_codes (identifier, code, expires_at) VALUES (?, ?, ?)
|
|
`
|
|
|
|
type CreateVerificationCodeParams struct {
|
|
Identifier string
|
|
Code string
|
|
ExpiresAt time.Time
|
|
}
|
|
|
|
func (q *Queries) CreateVerificationCode(ctx context.Context, arg CreateVerificationCodeParams) error {
|
|
_, err := q.db.ExecContext(ctx, createVerificationCode, arg.Identifier, arg.Code, arg.ExpiresAt)
|
|
return err
|
|
}
|
|
|
|
const deleteClaim = `-- name: DeleteClaim :exec
|
|
DELETE FROM claims WHERE id = ?
|
|
`
|
|
|
|
func (q *Queries) DeleteClaim(ctx context.Context, id int64) error {
|
|
_, err := q.db.ExecContext(ctx, deleteClaim, id)
|
|
return err
|
|
}
|
|
|
|
const deleteDuplicateRsvps = `-- name: DeleteDuplicateRsvps :exec
|
|
DELETE FROM rsvps WHERE id NOT IN (
|
|
SELECT MIN(id) FROM rsvps GROUP BY event_id, name COLLATE NOCASE
|
|
)
|
|
`
|
|
|
|
func (q *Queries) DeleteDuplicateRsvps(ctx context.Context) error {
|
|
_, err := q.db.ExecContext(ctx, deleteDuplicateRsvps)
|
|
return err
|
|
}
|
|
|
|
const deleteEvent = `-- name: DeleteEvent :exec
|
|
DELETE FROM events WHERE id = ?
|
|
`
|
|
|
|
func (q *Queries) DeleteEvent(ctx context.Context, id int64) error {
|
|
_, err := q.db.ExecContext(ctx, deleteEvent, id)
|
|
return err
|
|
}
|
|
|
|
const deleteExpiredSessions = `-- name: DeleteExpiredSessions :exec
|
|
DELETE FROM sessions WHERE expires_at <= CURRENT_TIMESTAMP
|
|
`
|
|
|
|
func (q *Queries) DeleteExpiredSessions(ctx context.Context) error {
|
|
_, err := q.db.ExecContext(ctx, deleteExpiredSessions)
|
|
return err
|
|
}
|
|
|
|
const deleteRsvp = `-- name: DeleteRsvp :exec
|
|
DELETE FROM rsvps WHERE id = ?
|
|
`
|
|
|
|
func (q *Queries) DeleteRsvp(ctx context.Context, id int64) error {
|
|
_, err := q.db.ExecContext(ctx, deleteRsvp, id)
|
|
return err
|
|
}
|
|
|
|
const deleteSession = `-- name: DeleteSession :exec
|
|
DELETE FROM sessions WHERE token = ?
|
|
`
|
|
|
|
func (q *Queries) DeleteSession(ctx context.Context, token string) error {
|
|
_, err := q.db.ExecContext(ctx, deleteSession, token)
|
|
return err
|
|
}
|
|
|
|
const deleteSlot = `-- name: DeleteSlot :exec
|
|
DELETE FROM slots WHERE id = ?
|
|
`
|
|
|
|
func (q *Queries) DeleteSlot(ctx context.Context, id int64) error {
|
|
_, err := q.db.ExecContext(ctx, deleteSlot, id)
|
|
return err
|
|
}
|
|
|
|
const getClaimByID = `-- name: GetClaimByID :one
|
|
SELECT id, slot_id, name, note, created_at FROM claims WHERE id = ?
|
|
`
|
|
|
|
func (q *Queries) GetClaimByID(ctx context.Context, id int64) (Claim, error) {
|
|
row := q.db.QueryRowContext(ctx, getClaimByID, id)
|
|
var i Claim
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.SlotID,
|
|
&i.Name,
|
|
&i.Note,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getEventByAdminToken = `-- name: GetEventByAdminToken :one
|
|
SELECT id, slug, title, date, time, location, admin_token, description, user_id, created_at FROM events WHERE admin_token = ?
|
|
`
|
|
|
|
func (q *Queries) GetEventByAdminToken(ctx context.Context, adminToken string) (Event, error) {
|
|
row := q.db.QueryRowContext(ctx, getEventByAdminToken, adminToken)
|
|
var i Event
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Slug,
|
|
&i.Title,
|
|
&i.Date,
|
|
&i.Time,
|
|
&i.Location,
|
|
&i.AdminToken,
|
|
&i.Description,
|
|
&i.UserID,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getEventBySlug = `-- name: GetEventBySlug :one
|
|
SELECT id, slug, title, date, time, location, admin_token, description, user_id, created_at FROM events WHERE slug = ?
|
|
`
|
|
|
|
func (q *Queries) GetEventBySlug(ctx context.Context, slug string) (Event, error) {
|
|
row := q.db.QueryRowContext(ctx, getEventBySlug, slug)
|
|
var i Event
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Slug,
|
|
&i.Title,
|
|
&i.Date,
|
|
&i.Time,
|
|
&i.Location,
|
|
&i.AdminToken,
|
|
&i.Description,
|
|
&i.UserID,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getRsvp = `-- name: GetRsvp :one
|
|
SELECT id, event_id, name, note, plus_one, created_at FROM rsvps WHERE id = ?
|
|
`
|
|
|
|
func (q *Queries) GetRsvp(ctx context.Context, id int64) (Rsvp, error) {
|
|
row := q.db.QueryRowContext(ctx, getRsvp, id)
|
|
var i Rsvp
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.EventID,
|
|
&i.Name,
|
|
&i.Note,
|
|
&i.PlusOne,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getRsvpByName = `-- name: GetRsvpByName :one
|
|
SELECT id, event_id, name, note, plus_one, created_at FROM rsvps WHERE event_id = ? AND name = ? COLLATE NOCASE LIMIT 1
|
|
`
|
|
|
|
type GetRsvpByNameParams struct {
|
|
EventID int64
|
|
Name string
|
|
}
|
|
|
|
func (q *Queries) GetRsvpByName(ctx context.Context, arg GetRsvpByNameParams) (Rsvp, error) {
|
|
row := q.db.QueryRowContext(ctx, getRsvpByName, arg.EventID, arg.Name)
|
|
var i Rsvp
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.EventID,
|
|
&i.Name,
|
|
&i.Note,
|
|
&i.PlusOne,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getSession = `-- name: GetSession :one
|
|
SELECT token, user_id, expires_at FROM sessions WHERE token = ? AND expires_at > CURRENT_TIMESTAMP
|
|
`
|
|
|
|
func (q *Queries) GetSession(ctx context.Context, token string) (Session, error) {
|
|
row := q.db.QueryRowContext(ctx, getSession, token)
|
|
var i Session
|
|
err := row.Scan(&i.Token, &i.UserID, &i.ExpiresAt)
|
|
return i, err
|
|
}
|
|
|
|
const getSlot = `-- name: GetSlot :one
|
|
SELECT id, event_id, name, emoji, max_claims, sort_order FROM slots WHERE id = ?
|
|
`
|
|
|
|
func (q *Queries) GetSlot(ctx context.Context, id int64) (Slot, error) {
|
|
row := q.db.QueryRowContext(ctx, getSlot, id)
|
|
var i Slot
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.EventID,
|
|
&i.Name,
|
|
&i.Emoji,
|
|
&i.MaxClaims,
|
|
&i.SortOrder,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserByEmail = `-- name: GetUserByEmail :one
|
|
SELECT id, phone, email, name, created_at FROM users WHERE email = ?
|
|
`
|
|
|
|
func (q *Queries) GetUserByEmail(ctx context.Context, email sql.NullString) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, getUserByEmail, email)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Phone,
|
|
&i.Email,
|
|
&i.Name,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserByPhone = `-- name: GetUserByPhone :one
|
|
SELECT id, phone, email, name, created_at FROM users WHERE phone = ?
|
|
`
|
|
|
|
func (q *Queries) GetUserByPhone(ctx context.Context, phone sql.NullString) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, getUserByPhone, phone)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Phone,
|
|
&i.Email,
|
|
&i.Name,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getVerificationCode = `-- name: GetVerificationCode :one
|
|
SELECT id, identifier, code, expires_at, used FROM verification_codes
|
|
WHERE identifier = ? AND code = ? AND used = 0 AND expires_at > CURRENT_TIMESTAMP
|
|
ORDER BY id DESC LIMIT 1
|
|
`
|
|
|
|
type GetVerificationCodeParams struct {
|
|
Identifier string
|
|
Code string
|
|
}
|
|
|
|
func (q *Queries) GetVerificationCode(ctx context.Context, arg GetVerificationCodeParams) (VerificationCode, error) {
|
|
row := q.db.QueryRowContext(ctx, getVerificationCode, arg.Identifier, arg.Code)
|
|
var i VerificationCode
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Identifier,
|
|
&i.Code,
|
|
&i.ExpiresAt,
|
|
&i.Used,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listClaimsByEvent = `-- name: ListClaimsByEvent :many
|
|
SELECT c.id, c.slot_id, c.name, c.note, c.created_at FROM claims c
|
|
JOIN slots s ON c.slot_id = s.id
|
|
WHERE s.event_id = ?
|
|
ORDER BY c.slot_id, c.created_at
|
|
`
|
|
|
|
func (q *Queries) ListClaimsByEvent(ctx context.Context, eventID int64) ([]Claim, error) {
|
|
rows, err := q.db.QueryContext(ctx, listClaimsByEvent, eventID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Claim
|
|
for rows.Next() {
|
|
var i Claim
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.SlotID,
|
|
&i.Name,
|
|
&i.Note,
|
|
&i.CreatedAt,
|
|
); 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 listClaimsBySlot = `-- name: ListClaimsBySlot :many
|
|
SELECT id, slot_id, name, note, created_at FROM claims WHERE slot_id = ? ORDER BY created_at
|
|
`
|
|
|
|
func (q *Queries) ListClaimsBySlot(ctx context.Context, slotID int64) ([]Claim, error) {
|
|
rows, err := q.db.QueryContext(ctx, listClaimsBySlot, slotID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Claim
|
|
for rows.Next() {
|
|
var i Claim
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.SlotID,
|
|
&i.Name,
|
|
&i.Note,
|
|
&i.CreatedAt,
|
|
); 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 listEventsByUser = `-- name: ListEventsByUser :many
|
|
SELECT id, slug, title, date, time, location, admin_token, description, user_id, created_at FROM events WHERE user_id = ? ORDER BY created_at DESC
|
|
`
|
|
|
|
func (q *Queries) ListEventsByUser(ctx context.Context, userID sql.NullInt64) ([]Event, error) {
|
|
rows, err := q.db.QueryContext(ctx, listEventsByUser, userID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Event
|
|
for rows.Next() {
|
|
var i Event
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Slug,
|
|
&i.Title,
|
|
&i.Date,
|
|
&i.Time,
|
|
&i.Location,
|
|
&i.AdminToken,
|
|
&i.Description,
|
|
&i.UserID,
|
|
&i.CreatedAt,
|
|
); 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 listRsvps = `-- name: ListRsvps :many
|
|
SELECT id, event_id, name, note, plus_one, created_at FROM rsvps WHERE event_id = ? ORDER BY created_at
|
|
`
|
|
|
|
func (q *Queries) ListRsvps(ctx context.Context, eventID int64) ([]Rsvp, error) {
|
|
rows, err := q.db.QueryContext(ctx, listRsvps, eventID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Rsvp
|
|
for rows.Next() {
|
|
var i Rsvp
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.EventID,
|
|
&i.Name,
|
|
&i.Note,
|
|
&i.PlusOne,
|
|
&i.CreatedAt,
|
|
); 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 listSlots = `-- name: ListSlots :many
|
|
SELECT id, event_id, name, emoji, max_claims, sort_order FROM slots WHERE event_id = ? ORDER BY sort_order, id
|
|
`
|
|
|
|
func (q *Queries) ListSlots(ctx context.Context, eventID int64) ([]Slot, error) {
|
|
rows, err := q.db.QueryContext(ctx, listSlots, eventID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Slot
|
|
for rows.Next() {
|
|
var i Slot
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.EventID,
|
|
&i.Name,
|
|
&i.Emoji,
|
|
&i.MaxClaims,
|
|
&i.SortOrder,
|
|
); 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 markVerificationCodeUsed = `-- name: MarkVerificationCodeUsed :exec
|
|
UPDATE verification_codes SET used = 1 WHERE id = ?
|
|
`
|
|
|
|
func (q *Queries) MarkVerificationCodeUsed(ctx context.Context, id int64) error {
|
|
_, err := q.db.ExecContext(ctx, markVerificationCodeUsed, id)
|
|
return err
|
|
}
|
|
|
|
const setEventUser = `-- name: SetEventUser :exec
|
|
UPDATE events SET user_id = ? WHERE id = ?
|
|
`
|
|
|
|
type SetEventUserParams struct {
|
|
UserID sql.NullInt64
|
|
ID int64
|
|
}
|
|
|
|
func (q *Queries) SetEventUser(ctx context.Context, arg SetEventUserParams) error {
|
|
_, err := q.db.ExecContext(ctx, setEventUser, arg.UserID, arg.ID)
|
|
return err
|
|
}
|
|
|
|
const updateEvent = `-- name: UpdateEvent :exec
|
|
UPDATE events SET title = ?, date = ?, time = ?, location = ? WHERE id = ?
|
|
`
|
|
|
|
type UpdateEventParams struct {
|
|
Title string
|
|
Date string
|
|
Time string
|
|
Location string
|
|
ID int64
|
|
}
|
|
|
|
func (q *Queries) UpdateEvent(ctx context.Context, arg UpdateEventParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateEvent,
|
|
arg.Title,
|
|
arg.Date,
|
|
arg.Time,
|
|
arg.Location,
|
|
arg.ID,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const updateEventDescription = `-- name: UpdateEventDescription :exec
|
|
UPDATE events SET description = ? WHERE id = ?
|
|
`
|
|
|
|
type UpdateEventDescriptionParams struct {
|
|
Description string
|
|
ID int64
|
|
}
|
|
|
|
func (q *Queries) UpdateEventDescription(ctx context.Context, arg UpdateEventDescriptionParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateEventDescription, arg.Description, arg.ID)
|
|
return err
|
|
}
|
|
|
|
const updateRsvp = `-- name: UpdateRsvp :exec
|
|
UPDATE rsvps SET name = ?, note = ?, plus_one = ? WHERE id = ?
|
|
`
|
|
|
|
type UpdateRsvpParams struct {
|
|
Name string
|
|
Note string
|
|
PlusOne int64
|
|
ID int64
|
|
}
|
|
|
|
func (q *Queries) UpdateRsvp(ctx context.Context, arg UpdateRsvpParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateRsvp,
|
|
arg.Name,
|
|
arg.Note,
|
|
arg.PlusOne,
|
|
arg.ID,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const updateSlot = `-- name: UpdateSlot :exec
|
|
UPDATE slots SET name = ?, emoji = ?, max_claims = ? WHERE id = ?
|
|
`
|
|
|
|
type UpdateSlotParams struct {
|
|
Name string
|
|
Emoji string
|
|
MaxClaims int64
|
|
ID int64
|
|
}
|
|
|
|
func (q *Queries) UpdateSlot(ctx context.Context, arg UpdateSlotParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateSlot,
|
|
arg.Name,
|
|
arg.Emoji,
|
|
arg.MaxClaims,
|
|
arg.ID,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const updateUserName = `-- name: UpdateUserName :exec
|
|
UPDATE users SET name = ? WHERE id = ?
|
|
`
|
|
|
|
type UpdateUserNameParams struct {
|
|
Name string
|
|
ID int64
|
|
}
|
|
|
|
func (q *Queries) UpdateUserName(ctx context.Context, arg UpdateUserNameParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateUserName, arg.Name, arg.ID)
|
|
return err
|
|
}
|