Yimaru-BackEnd/db/query/practice_questions.sql

35 lines
682 B
SQL

-- name: CreatePracticeQuestion :one
INSERT INTO practice_questions (
practice_id,
question,
question_voice_prompt,
sample_answer_voice_prompt,
sample_answer,
tips,
type
)
VALUES ($1, $2, $3, $4, $5, $6, $7)
RETURNING *;
-- name: GetQuestionsByPractice :many
SELECT *
FROM practice_questions
WHERE practice_id = $1
ORDER BY id ASC;
-- name: UpdatePracticeQuestion :exec
UPDATE practice_questions
SET
question = COALESCE($1, question),
sample_answer = COALESCE($2, sample_answer),
tips = COALESCE($3, tips),
type = COALESCE($4, type)
WHERE id = $5;
-- name: DeletePracticeQuestion :exec
DELETE FROM practice_questions
WHERE id = $1;