197 lines
4.9 KiB
Go
197 lines
4.9 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: queries.sql
|
|
|
|
package sqlcgen
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"encoding/json"
|
|
|
|
"github.com/lib/pq"
|
|
)
|
|
|
|
const getQuestionListByIDs = `-- name: GetQuestionListByIDs :many
|
|
SELECT id, quiz_id, title, description, questiontype, required, deleted, page, content, version, parent_ids, created_at, updated_at, session, auditory FROM question WHERE id = ANY($1::int[]) AND deleted = FALSE
|
|
`
|
|
|
|
func (q *Queries) GetQuestionListByIDs(ctx context.Context, dollar_1 []int32) ([]Question, error) {
|
|
rows, err := q.db.QueryContext(ctx, getQuestionListByIDs, pq.Array(dollar_1))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Question
|
|
for rows.Next() {
|
|
var i Question
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.QuizID,
|
|
&i.Title,
|
|
&i.Description,
|
|
&i.Questiontype,
|
|
&i.Required,
|
|
&i.Deleted,
|
|
&i.Page,
|
|
&i.Content,
|
|
&i.Version,
|
|
pq.Array(&i.ParentIds),
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.Session,
|
|
&i.Auditory,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const insertAnswers = `-- name: InsertAnswers :one
|
|
INSERT INTO answer(
|
|
content,
|
|
quiz_id,
|
|
question_id,
|
|
fingerprint,
|
|
session,
|
|
result,
|
|
email,
|
|
device_type,
|
|
device,
|
|
os,
|
|
browser,
|
|
ip,
|
|
start,
|
|
utm,
|
|
version
|
|
) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15)
|
|
RETURNING id, content, quiz_id, question_id, fingerprint, session, created_at, result, new, deleted, email, device_type, device, os, browser, ip, start, utm, version
|
|
`
|
|
|
|
type InsertAnswersParams struct {
|
|
Content sql.NullString `db:"content" json:"content"`
|
|
QuizID int64 `db:"quiz_id" json:"quiz_id"`
|
|
QuestionID int64 `db:"question_id" json:"question_id"`
|
|
Fingerprint sql.NullString `db:"fingerprint" json:"fingerprint"`
|
|
Session sql.NullString `db:"session" json:"session"`
|
|
Result sql.NullBool `db:"result" json:"result"`
|
|
Email string `db:"email" json:"email"`
|
|
DeviceType string `db:"device_type" json:"device_type"`
|
|
Device string `db:"device" json:"device"`
|
|
Os string `db:"os" json:"os"`
|
|
Browser string `db:"browser" json:"browser"`
|
|
Ip string `db:"ip" json:"ip"`
|
|
Start bool `db:"start" json:"start"`
|
|
Utm json.RawMessage `db:"utm" json:"utm"`
|
|
Version int32 `db:"version" json:"version"`
|
|
}
|
|
|
|
func (q *Queries) InsertAnswers(ctx context.Context, arg InsertAnswersParams) (Answer, error) {
|
|
row := q.db.QueryRowContext(ctx, insertAnswers,
|
|
arg.Content,
|
|
arg.QuizID,
|
|
arg.QuestionID,
|
|
arg.Fingerprint,
|
|
arg.Session,
|
|
arg.Result,
|
|
arg.Email,
|
|
arg.DeviceType,
|
|
arg.Device,
|
|
arg.Os,
|
|
arg.Browser,
|
|
arg.Ip,
|
|
arg.Start,
|
|
arg.Utm,
|
|
arg.Version,
|
|
)
|
|
var i Answer
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Content,
|
|
&i.QuizID,
|
|
&i.QuestionID,
|
|
&i.Fingerprint,
|
|
&i.Session,
|
|
&i.CreatedAt,
|
|
&i.Result,
|
|
&i.New,
|
|
&i.Deleted,
|
|
&i.Email,
|
|
&i.DeviceType,
|
|
&i.Device,
|
|
&i.Os,
|
|
&i.Browser,
|
|
&i.Ip,
|
|
&i.Start,
|
|
&i.Utm,
|
|
&i.Version,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const insertQuestion = `-- name: InsertQuestion :one
|
|
INSERT INTO question (
|
|
quiz_id,
|
|
title,
|
|
description,
|
|
questiontype,
|
|
required,
|
|
page,
|
|
content,
|
|
parent_ids,
|
|
updated_at,
|
|
session,
|
|
auditory
|
|
)
|
|
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11)
|
|
RETURNING id, created_at, updated_at
|
|
`
|
|
|
|
type InsertQuestionParams struct {
|
|
QuizID int64 `db:"quiz_id" json:"quiz_id"`
|
|
Title string `db:"title" json:"title"`
|
|
Description sql.NullString `db:"description" json:"description"`
|
|
Questiontype interface{} `db:"questiontype" json:"questiontype"`
|
|
Required sql.NullBool `db:"required" json:"required"`
|
|
Page sql.NullInt16 `db:"page" json:"page"`
|
|
Content sql.NullString `db:"content" json:"content"`
|
|
ParentIds []int32 `db:"parent_ids" json:"parent_ids"`
|
|
UpdatedAt sql.NullTime `db:"updated_at" json:"updated_at"`
|
|
Session string `db:"session" json:"session"`
|
|
Auditory int64 `db:"auditory" json:"auditory"`
|
|
}
|
|
|
|
type InsertQuestionRow struct {
|
|
ID int64 `db:"id" json:"id"`
|
|
CreatedAt sql.NullTime `db:"created_at" json:"created_at"`
|
|
UpdatedAt sql.NullTime `db:"updated_at" json:"updated_at"`
|
|
}
|
|
|
|
func (q *Queries) InsertQuestion(ctx context.Context, arg InsertQuestionParams) (InsertQuestionRow, error) {
|
|
row := q.db.QueryRowContext(ctx, insertQuestion,
|
|
arg.QuizID,
|
|
arg.Title,
|
|
arg.Description,
|
|
arg.Questiontype,
|
|
arg.Required,
|
|
arg.Page,
|
|
arg.Content,
|
|
pq.Array(arg.ParentIds),
|
|
arg.UpdatedAt,
|
|
arg.Session,
|
|
arg.Auditory,
|
|
)
|
|
var i InsertQuestionRow
|
|
err := row.Scan(&i.ID, &i.CreatedAt, &i.UpdatedAt)
|
|
return i, err
|
|
}
|