// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.30.0 // source: exam_prep_lesson_practices.sql package dbgen import ( "context" "github.com/jackc/pgx/v5/pgtype" ) const ExamPrepCreateLessonPractice = `-- name: ExamPrepCreateLessonPractice :one INSERT INTO exam_prep.lesson_practices ( unit_module_lesson_id, title, story_description, story_image, persona_id, question_set_id, quick_tips ) VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING id, unit_module_lesson_id, title, story_description, story_image, persona_id, question_set_id, quick_tips, created_at, updated_at ` type ExamPrepCreateLessonPracticeParams struct { UnitModuleLessonID int64 `json:"unit_module_lesson_id"` Title string `json:"title"` StoryDescription pgtype.Text `json:"story_description"` StoryImage pgtype.Text `json:"story_image"` PersonaID pgtype.Int8 `json:"persona_id"` QuestionSetID int64 `json:"question_set_id"` QuickTips pgtype.Text `json:"quick_tips"` } func (q *Queries) ExamPrepCreateLessonPractice(ctx context.Context, arg ExamPrepCreateLessonPracticeParams) (ExamPrepLessonPractice, error) { row := q.db.QueryRow(ctx, ExamPrepCreateLessonPractice, arg.UnitModuleLessonID, arg.Title, arg.StoryDescription, arg.StoryImage, arg.PersonaID, arg.QuestionSetID, arg.QuickTips, ) var i ExamPrepLessonPractice err := row.Scan( &i.ID, &i.UnitModuleLessonID, &i.Title, &i.StoryDescription, &i.StoryImage, &i.PersonaID, &i.QuestionSetID, &i.QuickTips, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const ExamPrepDeleteLessonPractice = `-- name: ExamPrepDeleteLessonPractice :exec DELETE FROM exam_prep.lesson_practices WHERE id = $1 ` func (q *Queries) ExamPrepDeleteLessonPractice(ctx context.Context, id int64) error { _, err := q.db.Exec(ctx, ExamPrepDeleteLessonPractice, id) return err } const ExamPrepGetLessonPracticeByID = `-- name: ExamPrepGetLessonPracticeByID :one SELECT id, unit_module_lesson_id, title, story_description, story_image, persona_id, question_set_id, quick_tips, created_at, updated_at FROM exam_prep.lesson_practices WHERE id = $1 ` func (q *Queries) ExamPrepGetLessonPracticeByID(ctx context.Context, id int64) (ExamPrepLessonPractice, error) { row := q.db.QueryRow(ctx, ExamPrepGetLessonPracticeByID, id) var i ExamPrepLessonPractice err := row.Scan( &i.ID, &i.UnitModuleLessonID, &i.Title, &i.StoryDescription, &i.StoryImage, &i.PersonaID, &i.QuestionSetID, &i.QuickTips, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const ExamPrepListLessonPracticesByLessonID = `-- name: ExamPrepListLessonPracticesByLessonID :many SELECT COUNT(*) OVER () AS total_count, p.id, p.unit_module_lesson_id, p.title, p.story_description, p.story_image, p.persona_id, p.question_set_id, p.quick_tips, p.created_at, p.updated_at FROM exam_prep.lesson_practices p WHERE p.unit_module_lesson_id = $1 ORDER BY p.created_at DESC LIMIT $2 OFFSET $3 ` type ExamPrepListLessonPracticesByLessonIDParams struct { UnitModuleLessonID int64 `json:"unit_module_lesson_id"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } type ExamPrepListLessonPracticesByLessonIDRow struct { TotalCount int64 `json:"total_count"` ID int64 `json:"id"` UnitModuleLessonID int64 `json:"unit_module_lesson_id"` Title string `json:"title"` StoryDescription pgtype.Text `json:"story_description"` StoryImage pgtype.Text `json:"story_image"` PersonaID pgtype.Int8 `json:"persona_id"` QuestionSetID int64 `json:"question_set_id"` QuickTips pgtype.Text `json:"quick_tips"` CreatedAt pgtype.Timestamptz `json:"created_at"` UpdatedAt pgtype.Timestamptz `json:"updated_at"` } func (q *Queries) ExamPrepListLessonPracticesByLessonID(ctx context.Context, arg ExamPrepListLessonPracticesByLessonIDParams) ([]ExamPrepListLessonPracticesByLessonIDRow, error) { rows, err := q.db.Query(ctx, ExamPrepListLessonPracticesByLessonID, arg.UnitModuleLessonID, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []ExamPrepListLessonPracticesByLessonIDRow for rows.Next() { var i ExamPrepListLessonPracticesByLessonIDRow if err := rows.Scan( &i.TotalCount, &i.ID, &i.UnitModuleLessonID, &i.Title, &i.StoryDescription, &i.StoryImage, &i.PersonaID, &i.QuestionSetID, &i.QuickTips, &i.CreatedAt, &i.UpdatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const ExamPrepUpdateLessonPractice = `-- name: ExamPrepUpdateLessonPractice :one UPDATE exam_prep.lesson_practices SET title = coalesce($1::varchar, title), story_description = coalesce($2::text, story_description), story_image = coalesce($3::text, story_image), persona_id = coalesce($4::bigint, persona_id), question_set_id = coalesce($5::bigint, question_set_id), quick_tips = coalesce($6::text, quick_tips), updated_at = CURRENT_TIMESTAMP WHERE id = $7 RETURNING id, unit_module_lesson_id, title, story_description, story_image, persona_id, question_set_id, quick_tips, created_at, updated_at ` type ExamPrepUpdateLessonPracticeParams struct { Title pgtype.Text `json:"title"` StoryDescription pgtype.Text `json:"story_description"` StoryImage pgtype.Text `json:"story_image"` PersonaID pgtype.Int8 `json:"persona_id"` QuestionSetID pgtype.Int8 `json:"question_set_id"` QuickTips pgtype.Text `json:"quick_tips"` ID int64 `json:"id"` } func (q *Queries) ExamPrepUpdateLessonPractice(ctx context.Context, arg ExamPrepUpdateLessonPracticeParams) (ExamPrepLessonPractice, error) { row := q.db.QueryRow(ctx, ExamPrepUpdateLessonPractice, arg.Title, arg.StoryDescription, arg.StoryImage, arg.PersonaID, arg.QuestionSetID, arg.QuickTips, arg.ID, ) var i ExamPrepLessonPractice err := row.Scan( &i.ID, &i.UnitModuleLessonID, &i.Title, &i.StoryDescription, &i.StoryImage, &i.PersonaID, &i.QuestionSetID, &i.QuickTips, &i.CreatedAt, &i.UpdatedAt, ) return i, err }