Files
bbq/db/queries.sql
T
ryan 8b32d98267 Initial commit: potluck signup app
Go + chi + SQLite + HTMX with SSE live updates.
Soft Brutalism design, emoji picker, Docker deploy.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-14 22:55:54 -04:00

54 lines
1.3 KiB
SQL

-- name: GetEventBySlug :one
SELECT * FROM events WHERE slug = ?;
-- name: GetEventByAdminToken :one
SELECT * FROM events WHERE admin_token = ?;
-- name: CreateEvent :one
INSERT INTO events (slug, title, date, time, location, admin_token)
VALUES (?, ?, ?, ?, ?, ?)
RETURNING *;
-- name: UpdateEvent :exec
UPDATE events SET title = ?, date = ?, time = ?, location = ? WHERE id = ?;
-- name: DeleteEvent :exec
DELETE FROM events WHERE id = ?;
-- name: ListSlots :many
SELECT * FROM slots WHERE event_id = ? ORDER BY sort_order, id;
-- name: GetSlot :one
SELECT * FROM slots WHERE id = ?;
-- name: CreateSlot :one
INSERT INTO slots (event_id, name, emoji, max_claims, sort_order)
VALUES (?, ?, ?, ?, ?)
RETURNING *;
-- name: UpdateSlot :exec
UPDATE slots SET name = ?, emoji = ?, max_claims = ? WHERE id = ?;
-- name: DeleteSlot :exec
DELETE FROM slots WHERE id = ?;
-- name: ListClaimsBySlot :many
SELECT * FROM claims WHERE slot_id = ? ORDER BY created_at;
-- name: ListClaimsByEvent :many
SELECT c.* FROM claims c
JOIN slots s ON c.slot_id = s.id
WHERE s.event_id = ?
ORDER BY c.slot_id, c.created_at;
-- name: CreateClaim :one
INSERT INTO claims (slot_id, name, note)
VALUES (?, ?, ?)
RETURNING *;
-- name: DeleteClaim :exec
DELETE FROM claims WHERE id = ?;
-- name: CountClaimsBySlot :one
SELECT COUNT(*) FROM claims WHERE slot_id = ?;