Files
BoostAI/Backend/db/queries/questions.sql
2026-05-25 17:05:06 +01:00

56 lines
824 B
SQL

-- name: CreateQuestion :one
INSERT INTO questions (
author_teacher_id,
title,
prompt,
topic,
subject,
difficulty,
source,
status,
correct_answer
) VALUES (
$1,
$2,
$3,
$4,
$5,
$6,
$7,
$8,
$9
)
RETURNING *;
-- name: ListQuestionsByTeacher :many
SELECT *
FROM questions
WHERE author_teacher_id = $1
ORDER BY created_at DESC;
-- name: GetQuestionByID :one
SELECT *
FROM questions
WHERE id = $1;
-- name: CreateTag :one
INSERT INTO tags (name)
VALUES ($1)
ON CONFLICT (name) DO UPDATE SET name = EXCLUDED.name
RETURNING *;
-- name: AttachTagToQuestion :exec
INSERT INTO question_tags (
question_id,
tag_id
) VALUES (
$1,
$2
)
ON CONFLICT (question_id, tag_id) DO NOTHING;
-- name: ListTags :many
SELECT *
FROM tags
ORDER BY name ASC;