// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.30.0 // source: lms_practices.sql package dbgen import ( "context" "github.com/jackc/pgx/v5/pgtype" ) const CreateLmsPractice = `-- name: CreateLmsPractice :one INSERT INTO lms_practices ( course_id, module_id, lesson_id, title, story_description, story_image, persona_id, question_set_id, quick_tips ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING id, course_id, module_id, lesson_id, title, story_description, story_image, persona_id, question_set_id, quick_tips, created_at, updated_at ` type CreateLmsPracticeParams struct { CourseID pgtype.Int8 `json:"course_id"` ModuleID pgtype.Int8 `json:"module_id"` LessonID pgtype.Int8 `json:"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) CreateLmsPractice(ctx context.Context, arg CreateLmsPracticeParams) (LmsPractice, error) { row := q.db.QueryRow(ctx, CreateLmsPractice, arg.CourseID, arg.ModuleID, arg.LessonID, arg.Title, arg.StoryDescription, arg.StoryImage, arg.PersonaID, arg.QuestionSetID, arg.QuickTips, ) var i LmsPractice err := row.Scan( &i.ID, &i.CourseID, &i.ModuleID, &i.LessonID, &i.Title, &i.StoryDescription, &i.StoryImage, &i.PersonaID, &i.QuestionSetID, &i.QuickTips, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const DeleteLmsPractice = `-- name: DeleteLmsPractice :exec DELETE FROM lms_practices WHERE id = $1 ` func (q *Queries) DeleteLmsPractice(ctx context.Context, id int64) error { _, err := q.db.Exec(ctx, DeleteLmsPractice, id) return err } const GetLmsPracticeByID = `-- name: GetLmsPracticeByID :one SELECT id, course_id, module_id, lesson_id, title, story_description, story_image, persona_id, question_set_id, quick_tips, created_at, updated_at FROM lms_practices WHERE id = $1 ` func (q *Queries) GetLmsPracticeByID(ctx context.Context, id int64) (LmsPractice, error) { row := q.db.QueryRow(ctx, GetLmsPracticeByID, id) var i LmsPractice err := row.Scan( &i.ID, &i.CourseID, &i.ModuleID, &i.LessonID, &i.Title, &i.StoryDescription, &i.StoryImage, &i.PersonaID, &i.QuestionSetID, &i.QuickTips, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const ListLmsPracticesByCourseID = `-- name: ListLmsPracticesByCourseID :many SELECT COUNT(*) OVER () AS total_count, p.id, p.course_id, p.module_id, p.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 lms_practices p WHERE p.course_id = $1 ORDER BY p.created_at DESC LIMIT $2 OFFSET $3 ` type ListLmsPracticesByCourseIDParams struct { CourseID pgtype.Int8 `json:"course_id"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } type ListLmsPracticesByCourseIDRow struct { TotalCount int64 `json:"total_count"` ID int64 `json:"id"` CourseID pgtype.Int8 `json:"course_id"` ModuleID pgtype.Int8 `json:"module_id"` LessonID pgtype.Int8 `json:"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) ListLmsPracticesByCourseID(ctx context.Context, arg ListLmsPracticesByCourseIDParams) ([]ListLmsPracticesByCourseIDRow, error) { rows, err := q.db.Query(ctx, ListLmsPracticesByCourseID, arg.CourseID, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []ListLmsPracticesByCourseIDRow for rows.Next() { var i ListLmsPracticesByCourseIDRow if err := rows.Scan( &i.TotalCount, &i.ID, &i.CourseID, &i.ModuleID, &i.LessonID, &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 ListLmsPracticesByLessonID = `-- name: ListLmsPracticesByLessonID :many SELECT COUNT(*) OVER () AS total_count, p.id, p.course_id, p.module_id, p.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 lms_practices p WHERE p.lesson_id = $1 ORDER BY p.created_at DESC LIMIT $2 OFFSET $3 ` type ListLmsPracticesByLessonIDParams struct { LessonID pgtype.Int8 `json:"lesson_id"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } type ListLmsPracticesByLessonIDRow struct { TotalCount int64 `json:"total_count"` ID int64 `json:"id"` CourseID pgtype.Int8 `json:"course_id"` ModuleID pgtype.Int8 `json:"module_id"` LessonID pgtype.Int8 `json:"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) ListLmsPracticesByLessonID(ctx context.Context, arg ListLmsPracticesByLessonIDParams) ([]ListLmsPracticesByLessonIDRow, error) { rows, err := q.db.Query(ctx, ListLmsPracticesByLessonID, arg.LessonID, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []ListLmsPracticesByLessonIDRow for rows.Next() { var i ListLmsPracticesByLessonIDRow if err := rows.Scan( &i.TotalCount, &i.ID, &i.CourseID, &i.ModuleID, &i.LessonID, &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 ListLmsPracticesByModuleID = `-- name: ListLmsPracticesByModuleID :many SELECT COUNT(*) OVER () AS total_count, p.id, p.course_id, p.module_id, p.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 lms_practices p WHERE p.module_id = $1 ORDER BY p.created_at DESC LIMIT $2 OFFSET $3 ` type ListLmsPracticesByModuleIDParams struct { ModuleID pgtype.Int8 `json:"module_id"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } type ListLmsPracticesByModuleIDRow struct { TotalCount int64 `json:"total_count"` ID int64 `json:"id"` CourseID pgtype.Int8 `json:"course_id"` ModuleID pgtype.Int8 `json:"module_id"` LessonID pgtype.Int8 `json:"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) ListLmsPracticesByModuleID(ctx context.Context, arg ListLmsPracticesByModuleIDParams) ([]ListLmsPracticesByModuleIDRow, error) { rows, err := q.db.Query(ctx, ListLmsPracticesByModuleID, arg.ModuleID, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []ListLmsPracticesByModuleIDRow for rows.Next() { var i ListLmsPracticesByModuleIDRow if err := rows.Scan( &i.TotalCount, &i.ID, &i.CourseID, &i.ModuleID, &i.LessonID, &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 UpdateLmsPractice = `-- name: UpdateLmsPractice :one UPDATE lms_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, course_id, module_id, lesson_id, title, story_description, story_image, persona_id, question_set_id, quick_tips, created_at, updated_at ` type UpdateLmsPracticeParams 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) UpdateLmsPractice(ctx context.Context, arg UpdateLmsPracticeParams) (LmsPractice, error) { row := q.db.QueryRow(ctx, UpdateLmsPractice, arg.Title, arg.StoryDescription, arg.StoryImage, arg.PersonaID, arg.QuestionSetID, arg.QuickTips, arg.ID, ) var i LmsPractice err := row.Scan( &i.ID, &i.CourseID, &i.ModuleID, &i.LessonID, &i.Title, &i.StoryDescription, &i.StoryImage, &i.PersonaID, &i.QuestionSetID, &i.QuickTips, &i.CreatedAt, &i.UpdatedAt, ) return i, err }