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

Method Create

13-GraphQL/internal/database/category.go:20–28  ·  view source on GitHub ↗
(name string, description string)

Source from the content-addressed store, hash-verified

18}
19
20func (c *Category) Create(name string, description string) (Category, error) {
21 id := uuid.New().String()
22 _, err := c.db.Exec("INSERT INTO categories (id, name, description) VALUES ($1, $2, $3)",
23 id, name, description)
24 if err != nil {
25 return Category{}, err
26 }
27 return Category{ID: id, Name: name, Description: description}, nil
28}
29
30func (c *Category) FindAll() ([]Category, error) {
31 rows, err := c.db.Query("SELECT id, name, description FROM categories")

Callers

nothing calls this directly

Calls 2

StringMethod · 0.45
ExecMethod · 0.45

Tested by

no test coverage detected