invitea/database/sqlc/queries/invites.sql

27 lines
450 B
SQL

-- name: GetInvite :one
SELECT * FROM invites
WHERE code = ? LIMIT 1;
-- name: ListInvites :many
SELECT * FROM invites
ORDER BY id DESC;
-- name: CreateInvite :one
INSERT INTO invites (
code, uses, total, expiration
) VALUES (
?, ?, ?, ?
)
RETURNING *;
-- name: UpdateInvite :exec
UPDATE invites
SET uses = ?
WHERE id = ?;
-- name: DeleteInvite :exec
DELETE FROM invites
WHERE id = ?;
-- name: CountInvites :one
SELECT count(*) FROM invites;