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

Method Create

13-GraphQL/internal/database/course.go:21–34  ·  view source on GitHub ↗
(name, description, categoryID string)

Source from the content-addressed store, hash-verified

19}
20
21func (c *Course) Create(name, description, categoryID string) (*Course, error) {
22 id := uuid.New().String()
23 _, err := c.db.Exec("INSERT INTO courses (id, name, description, category_id) VALUES ($1, $2, $3, $4)",
24 id, name, description, categoryID)
25 if err != nil {
26 return nil, err
27 }
28 return &Course{
29 ID: id,
30 Name: name,
31 Description: description,
32 CategoryID: categoryID,
33 }, nil
34}
35
36func (c *Course) FindAll() ([]Course, error) {
37 rows, err := c.db.Query("SELECT id, name, description, category_id FROM courses")

Callers

nothing calls this directly

Calls 2

StringMethod · 0.45
ExecMethod · 0.45

Tested by

no test coverage detected