111 lines
3.0 KiB
Go
111 lines
3.0 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: question_short_answers.sql
|
|
|
|
package dbgen
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const CreateQuestionShortAnswer = `-- name: CreateQuestionShortAnswer :one
|
|
INSERT INTO question_short_answers (
|
|
question_id,
|
|
acceptable_answer,
|
|
match_type
|
|
)
|
|
VALUES ($1, $2, COALESCE($3, 'EXACT'))
|
|
RETURNING id, question_id, acceptable_answer, match_type, created_at
|
|
`
|
|
|
|
type CreateQuestionShortAnswerParams struct {
|
|
QuestionID int64 `json:"question_id"`
|
|
AcceptableAnswer string `json:"acceptable_answer"`
|
|
Column3 interface{} `json:"column_3"`
|
|
}
|
|
|
|
func (q *Queries) CreateQuestionShortAnswer(ctx context.Context, arg CreateQuestionShortAnswerParams) (QuestionShortAnswer, error) {
|
|
row := q.db.QueryRow(ctx, CreateQuestionShortAnswer, arg.QuestionID, arg.AcceptableAnswer, arg.Column3)
|
|
var i QuestionShortAnswer
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.QuestionID,
|
|
&i.AcceptableAnswer,
|
|
&i.MatchType,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const DeleteQuestionShortAnswer = `-- name: DeleteQuestionShortAnswer :exec
|
|
DELETE FROM question_short_answers
|
|
WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteQuestionShortAnswer(ctx context.Context, id int64) error {
|
|
_, err := q.db.Exec(ctx, DeleteQuestionShortAnswer, id)
|
|
return err
|
|
}
|
|
|
|
const DeleteShortAnswersByQuestionID = `-- name: DeleteShortAnswersByQuestionID :exec
|
|
DELETE FROM question_short_answers
|
|
WHERE question_id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteShortAnswersByQuestionID(ctx context.Context, questionID int64) error {
|
|
_, err := q.db.Exec(ctx, DeleteShortAnswersByQuestionID, questionID)
|
|
return err
|
|
}
|
|
|
|
const GetShortAnswersByQuestionID = `-- name: GetShortAnswersByQuestionID :many
|
|
SELECT id, question_id, acceptable_answer, match_type, created_at
|
|
FROM question_short_answers
|
|
WHERE question_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetShortAnswersByQuestionID(ctx context.Context, questionID int64) ([]QuestionShortAnswer, error) {
|
|
rows, err := q.db.Query(ctx, GetShortAnswersByQuestionID, questionID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []QuestionShortAnswer
|
|
for rows.Next() {
|
|
var i QuestionShortAnswer
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.QuestionID,
|
|
&i.AcceptableAnswer,
|
|
&i.MatchType,
|
|
&i.CreatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const UpdateQuestionShortAnswer = `-- name: UpdateQuestionShortAnswer :exec
|
|
UPDATE question_short_answers
|
|
SET
|
|
acceptable_answer = COALESCE($1, acceptable_answer),
|
|
match_type = COALESCE($2, match_type)
|
|
WHERE id = $3
|
|
`
|
|
|
|
type UpdateQuestionShortAnswerParams struct {
|
|
AcceptableAnswer string `json:"acceptable_answer"`
|
|
MatchType string `json:"match_type"`
|
|
ID int64 `json:"id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateQuestionShortAnswer(ctx context.Context, arg UpdateQuestionShortAnswerParams) error {
|
|
_, err := q.db.Exec(ctx, UpdateQuestionShortAnswer, arg.AcceptableAnswer, arg.MatchType, arg.ID)
|
|
return err
|
|
}
|