set and get now work trough endpoint api

This commit is contained in:
zipfriis
2026-03-25 17:44:04 +01:00
parent b9f462f5be
commit e056d8a37e
7 changed files with 82 additions and 18 deletions

View File

@@ -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
}