MCPcopy Create free account
hub / github.com/devfullcycle/goexpert / CreateCourseAndCategory

Method CreateCourseAndCategory

17-SQLC/cmd/runSQLCTX/main.go:54–81  ·  view source on GitHub ↗
(ctx context.Context, argsCategory CategoryParams, argsCourse CourseParams)

Source from the content-addressed store, hash-verified

52}
53
54func (c *CourseDB) CreateCourseAndCategory(ctx context.Context, argsCategory CategoryParams, argsCourse CourseParams) error {
55 err := c.callTx(ctx, func(q *db.Queries) error {
56 var err error
57 err = q.CreateCategory(ctx, db.CreateCategoryParams{
58 ID: argsCategory.ID,
59 Name: argsCategory.Name,
60 Description: argsCategory.Description,
61 })
62 if err != nil {
63 return err
64 }
65 err = q.CreateCourse(ctx, db.CreateCourseParams{
66 ID: argsCourse.ID,
67 Name: argsCourse.Name,
68 Description: argsCourse.Description,
69 CategoryID: argsCategory.ID,
70 Price: argsCourse.Price,
71 })
72 if err != nil {
73 return err
74 }
75 return nil
76 })
77 if err != nil {
78 return err
79 }
80 return nil
81}
82
83func main() {
84 ctx := context.Background()

Callers

nothing calls this directly

Calls 3

callTxMethod · 0.95
CreateCategoryMethod · 0.65
CreateCourseMethod · 0.65

Tested by

no test coverage detected