-- name: CreateCourse :one INSERT INTO courses ( category_id, title, description, thumbnail, intro_video_url, is_active ) VALUES ($1, $2, $3, $4, $5, COALESCE($6, true)) RETURNING *; -- name: GetCourseByID :one SELECT * FROM courses WHERE id = $1; -- name: GetCoursesByCategory :many SELECT COUNT(*) OVER () AS total_count, id, category_id, title, description, thumbnail, intro_video_url, is_active FROM courses WHERE category_id = $1 ORDER BY id DESC LIMIT sqlc.narg('limit')::INT OFFSET sqlc.narg('offset')::INT; -- name: UpdateCourse :exec UPDATE courses SET title = COALESCE($1, title), description = COALESCE($2, description), thumbnail = COALESCE($3, thumbnail), intro_video_url = COALESCE($4, intro_video_url), is_active = COALESCE($5, is_active) WHERE id = $6; -- name: DeleteCourse :exec DELETE FROM courses WHERE id = $1;