125 lines
3.3 KiB
Go
125 lines
3.3 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: user_audio_responses.sql
|
|
|
|
package dbgen
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const CreateUserAudioResponse = `-- name: CreateUserAudioResponse :one
|
|
INSERT INTO user_audio_responses (user_id, question_id, question_set_id, audio_object_key)
|
|
VALUES ($1, $2, $3, $4)
|
|
RETURNING id, user_id, question_id, question_set_id, audio_object_key, created_at
|
|
`
|
|
|
|
type CreateUserAudioResponseParams struct {
|
|
UserID int64 `json:"user_id"`
|
|
QuestionID int64 `json:"question_id"`
|
|
QuestionSetID int64 `json:"question_set_id"`
|
|
AudioObjectKey string `json:"audio_object_key"`
|
|
}
|
|
|
|
func (q *Queries) CreateUserAudioResponse(ctx context.Context, arg CreateUserAudioResponseParams) (UserAudioResponse, error) {
|
|
row := q.db.QueryRow(ctx, CreateUserAudioResponse,
|
|
arg.UserID,
|
|
arg.QuestionID,
|
|
arg.QuestionSetID,
|
|
arg.AudioObjectKey,
|
|
)
|
|
var i UserAudioResponse
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.UserID,
|
|
&i.QuestionID,
|
|
&i.QuestionSetID,
|
|
&i.AudioObjectKey,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const DeleteUserAudioResponse = `-- name: DeleteUserAudioResponse :exec
|
|
DELETE FROM user_audio_responses
|
|
WHERE id = $1 AND user_id = $2
|
|
`
|
|
|
|
type DeleteUserAudioResponseParams struct {
|
|
ID int64 `json:"id"`
|
|
UserID int64 `json:"user_id"`
|
|
}
|
|
|
|
func (q *Queries) DeleteUserAudioResponse(ctx context.Context, arg DeleteUserAudioResponseParams) error {
|
|
_, err := q.db.Exec(ctx, DeleteUserAudioResponse, arg.ID, arg.UserID)
|
|
return err
|
|
}
|
|
|
|
const GetUserAudioResponse = `-- name: GetUserAudioResponse :one
|
|
SELECT id, user_id, question_id, question_set_id, audio_object_key, created_at
|
|
FROM user_audio_responses
|
|
WHERE user_id = $1 AND question_id = $2 AND question_set_id = $3
|
|
ORDER BY created_at DESC
|
|
LIMIT 1
|
|
`
|
|
|
|
type GetUserAudioResponseParams struct {
|
|
UserID int64 `json:"user_id"`
|
|
QuestionID int64 `json:"question_id"`
|
|
QuestionSetID int64 `json:"question_set_id"`
|
|
}
|
|
|
|
func (q *Queries) GetUserAudioResponse(ctx context.Context, arg GetUserAudioResponseParams) (UserAudioResponse, error) {
|
|
row := q.db.QueryRow(ctx, GetUserAudioResponse, arg.UserID, arg.QuestionID, arg.QuestionSetID)
|
|
var i UserAudioResponse
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.UserID,
|
|
&i.QuestionID,
|
|
&i.QuestionSetID,
|
|
&i.AudioObjectKey,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const ListUserAudioResponsesBySet = `-- name: ListUserAudioResponsesBySet :many
|
|
SELECT id, user_id, question_id, question_set_id, audio_object_key, created_at
|
|
FROM user_audio_responses
|
|
WHERE user_id = $1 AND question_set_id = $2
|
|
ORDER BY created_at DESC
|
|
`
|
|
|
|
type ListUserAudioResponsesBySetParams struct {
|
|
UserID int64 `json:"user_id"`
|
|
QuestionSetID int64 `json:"question_set_id"`
|
|
}
|
|
|
|
func (q *Queries) ListUserAudioResponsesBySet(ctx context.Context, arg ListUserAudioResponsesBySetParams) ([]UserAudioResponse, error) {
|
|
rows, err := q.db.Query(ctx, ListUserAudioResponsesBySet, arg.UserID, arg.QuestionSetID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []UserAudioResponse
|
|
for rows.Next() {
|
|
var i UserAudioResponse
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.UserID,
|
|
&i.QuestionID,
|
|
&i.QuestionSetID,
|
|
&i.AudioObjectKey,
|
|
&i.CreatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|