Skip to content

Commit da38319

Browse files
adding get product
1 parent 7d9768b commit da38319

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ecomm-api/storer/storer_mysql.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,14 @@ res,err := ns.db.NameExecContext (ctx,"INSERT INTO PRODUCTS (name,image,category
3232
}
3333

3434

35+
func (ms *MySQLStorer) GetProduct (ctx context.Context,id int64) (*Product,error){
36+
var p Product
37+
err := ms.db.GetContext(ctx,&p,"SELECT * FROM products where id=?",id)
38+
if err !=nil {
39+
return nil, fmt.Errorf("Error getting product: %w",err)
40+
}
41+
42+
return &p,nil
43+
}
44+
3545

0 commit comments

Comments
 (0)