93 lines
2.4 KiB
Go
93 lines
2.4 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: question_audio_answers.sql
|
|
|
|
package dbgen
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const CreateQuestionAudioAnswer = `-- name: CreateQuestionAudioAnswer :one
|
|
INSERT INTO question_audio_answers (question_id, correct_answer_text)
|
|
VALUES ($1, $2)
|
|
RETURNING id, question_id, correct_answer_text, created_at
|
|
`
|
|
|
|
type CreateQuestionAudioAnswerParams struct {
|
|
QuestionID int64 `json:"question_id"`
|
|
CorrectAnswerText string `json:"correct_answer_text"`
|
|
}
|
|
|
|
func (q *Queries) CreateQuestionAudioAnswer(ctx context.Context, arg CreateQuestionAudioAnswerParams) (QuestionAudioAnswer, error) {
|
|
row := q.db.QueryRow(ctx, CreateQuestionAudioAnswer, arg.QuestionID, arg.CorrectAnswerText)
|
|
var i QuestionAudioAnswer
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.QuestionID,
|
|
&i.CorrectAnswerText,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const DeleteAudioAnswerByQuestionID = `-- name: DeleteAudioAnswerByQuestionID :exec
|
|
DELETE FROM question_audio_answers
|
|
WHERE question_id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteAudioAnswerByQuestionID(ctx context.Context, questionID int64) error {
|
|
_, err := q.db.Exec(ctx, DeleteAudioAnswerByQuestionID, questionID)
|
|
return err
|
|
}
|
|
|
|
const GetAudioAnswerByQuestionID = `-- name: GetAudioAnswerByQuestionID :one
|
|
SELECT id, question_id, correct_answer_text, created_at
|
|
FROM question_audio_answers
|
|
WHERE question_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetAudioAnswerByQuestionID(ctx context.Context, questionID int64) (QuestionAudioAnswer, error) {
|
|
row := q.db.QueryRow(ctx, GetAudioAnswerByQuestionID, questionID)
|
|
var i QuestionAudioAnswer
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.QuestionID,
|
|
&i.CorrectAnswerText,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const GetAudioAnswersByQuestionIDs = `-- name: GetAudioAnswersByQuestionIDs :many
|
|
SELECT id, question_id, correct_answer_text, created_at
|
|
FROM question_audio_answers
|
|
WHERE question_id = ANY($1::BIGINT[])
|
|
`
|
|
|
|
func (q *Queries) GetAudioAnswersByQuestionIDs(ctx context.Context, dollar_1 []int64) ([]QuestionAudioAnswer, error) {
|
|
rows, err := q.db.Query(ctx, GetAudioAnswersByQuestionIDs, dollar_1)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []QuestionAudioAnswer
|
|
for rows.Next() {
|
|
var i QuestionAudioAnswer
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.QuestionID,
|
|
&i.CorrectAnswerText,
|
|
&i.CreatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|