MCPcopy Create free account
hub / github.com/dreamsofcode-io/grpc / Insert

Method Insert

pokemon-api/pokedex/repo.go:25–40  ·  view source on GitHub ↗
(ctx context.Context, pokemon Pokemon)

Source from the content-addressed store, hash-verified

23}
24
25func (p *Repository) Insert(ctx context.Context, pokemon Pokemon) error {
26 _, err := p.db.Exec(
27 ctx,
28 "INSERT INTO pokemon (id, name, types, created_at, updated_at) VALUES ($1, $2, $3, $4, $5)",
29 pokemon.ID,
30 pokemon.Name,
31 pokemon.Types,
32 pokemon.CreatedAt,
33 pokemon.UpdatedAt,
34 )
35 if err != nil {
36 return fmt.Errorf("failed to insert pokemon: %w", err)
37 }
38
39 return nil
40}
41
42func (p *Repository) FindAll(ctx context.Context) ([]Pokemon, error) {
43 rows, err := p.db.Query(ctx, "SELECT id, name, types, created_at, updated_at FROM pokemon")

Callers 1

CreateMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected