set and get now work trough endpoint api
This commit is contained in:
@@ -19,3 +19,15 @@ func GetCurrencyByID(db *sql.DB, ID int) (model.Currency, error) {
|
||||
}
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func GetCurrencyByCode(db *sql.DB, Code string) (model.Currency, error) {
|
||||
var c model.Currency
|
||||
err := db.QueryRow(
|
||||
`SELECT id, code, name, FROM currencies WHERE code = ?`,
|
||||
Code,
|
||||
).Scan(&c.ID, &c.Code, &c.Name)
|
||||
if err == sql.ErrNoRows {
|
||||
return c, fmt.Errorf("company %d not found", Code)
|
||||
}
|
||||
return c, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user