// 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 ExamPrepCreatePractice = `-- name: ExamPrepCreatePractice :one INSERT INTO exam_prep.lesson_practices ( title, story_description, story_image, persona_id, question_set_id, quick_tips, publish_status ) VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING id, title, story_description, story_image, persona_id, question_set_id, quick_tips, created_at, updated_at, publish_status ` type ExamPrepCreatePracticeParams struct { 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"` PublishStatus string `json:"publish_status"` } func (q *Queries) ExamPrepCreatePractice(ctx context.Context, arg ExamPrepCreatePracticeParams) (ExamPrepLessonPractice, error) { row := q.db.QueryRow(ctx, ExamPrepCreatePractice, arg.Title, arg.StoryDescription, arg.StoryImage, arg.PersonaID, arg.QuestionSetID, arg.QuickTips, arg.PublishStatus, ) var i ExamPrepLessonPractice err := row.Scan( &i.ID, &i.Title, &i.StoryDescription, &i.StoryImage, &i.PersonaID, &i.QuestionSetID, &i.QuickTips, &i.CreatedAt, &i.UpdatedAt, &i.PublishStatus, ) 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, title, story_description, story_image, persona_id, question_set_id, quick_tips, created_at, updated_at, publish_status 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.Title, &i.StoryDescription, &i.StoryImage, &i.PersonaID, &i.QuestionSetID, &i.QuickTips, &i.CreatedAt, &i.UpdatedAt, &i.PublishStatus, ) return i, err } const ExamPrepGetLessonPracticeByQuestionSetID = `-- name: ExamPrepGetLessonPracticeByQuestionSetID :one SELECT id, title, story_description, story_image, persona_id, question_set_id, quick_tips, created_at, updated_at, publish_status FROM exam_prep.lesson_practices WHERE question_set_id = $1 ORDER BY id DESC LIMIT 1 ` func (q *Queries) ExamPrepGetLessonPracticeByQuestionSetID(ctx context.Context, questionSetID int64) (ExamPrepLessonPractice, error) { row := q.db.QueryRow(ctx, ExamPrepGetLessonPracticeByQuestionSetID, questionSetID) var i ExamPrepLessonPractice err := row.Scan( &i.ID, &i.Title, &i.StoryDescription, &i.StoryImage, &i.PersonaID, &i.QuestionSetID, &i.QuickTips, &i.CreatedAt, &i.UpdatedAt, &i.PublishStatus, ) return i, err } const ExamPrepListPracticesByParent = `-- name: ExamPrepListPracticesByParent :many SELECT COUNT(*) OVER () AS total_count, p.id, p.title, p.story_description, p.story_image, p.persona_id, p.question_set_id, p.quick_tips, p.publish_status, p.created_at, p.updated_at FROM exam_prep.lesson_practices p INNER JOIN exam_prep.practice_parents pp ON pp.practice_id = p.id WHERE pp.parent_kind = $3::varchar AND pp.parent_id = $4::bigint AND ( $5::boolean = FALSE OR p.publish_status = 'PUBLISHED'::TEXT ) ORDER BY p.created_at DESC LIMIT $1 OFFSET $2 ` type ExamPrepListPracticesByParentParams struct { Limit int32 `json:"limit"` Offset int32 `json:"offset"` ParentKind string `json:"parent_kind"` ParentID int64 `json:"parent_id"` PublishedOnly bool `json:"published_only"` } type ExamPrepListPracticesByParentRow struct { TotalCount int64 `json:"total_count"` ID int64 `json:"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"` PublishStatus string `json:"publish_status"` CreatedAt pgtype.Timestamptz `json:"created_at"` UpdatedAt pgtype.Timestamptz `json:"updated_at"` } func (q *Queries) ExamPrepListPracticesByParent(ctx context.Context, arg ExamPrepListPracticesByParentParams) ([]ExamPrepListPracticesByParentRow, error) { rows, err := q.db.Query(ctx, ExamPrepListPracticesByParent, arg.Limit, arg.Offset, arg.ParentKind, arg.ParentID, arg.PublishedOnly, ) if err != nil { return nil, err } defer rows.Close() var items []ExamPrepListPracticesByParentRow for rows.Next() { var i ExamPrepListPracticesByParentRow if err := rows.Scan( &i.TotalCount, &i.ID, &i.Title, &i.StoryDescription, &i.StoryImage, &i.PersonaID, &i.QuestionSetID, &i.QuickTips, &i.PublishStatus, &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), publish_status = coalesce($7::varchar, publish_status), updated_at = CURRENT_TIMESTAMP WHERE id = $8 RETURNING id, title, story_description, story_image, persona_id, question_set_id, quick_tips, created_at, updated_at, publish_status ` 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"` PublishStatus pgtype.Text `json:"publish_status"` 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.PublishStatus, arg.ID, ) var i ExamPrepLessonPractice err := row.Scan( &i.ID, &i.Title, &i.StoryDescription, &i.StoryImage, &i.PersonaID, &i.QuestionSetID, &i.QuickTips, &i.CreatedAt, &i.UpdatedAt, &i.PublishStatus, ) return i, err }