update of posotion by trade his
This commit is contained in:
@@ -8,6 +8,22 @@ import (
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
func GetCompanyBySymbol(db *sql.DB, symbol string) (*model.Company, error) {
|
||||
var c model.Company
|
||||
err := db.QueryRow(
|
||||
`SELECT id, symbol, shares_outstanding, price, currency_id FROM companies WHERE symbol = ?`,
|
||||
symbol,
|
||||
).Scan(&c.ID, &c.Symbol, &c.SharesOutstanding, &c.Price, &c.CurrencyID)
|
||||
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("query company: %w", err)
|
||||
}
|
||||
return &c, nil
|
||||
}
|
||||
|
||||
func GetCompanyByID(db *sql.DB, id int) (*model.Company, error) {
|
||||
var c model.Company
|
||||
err := db.QueryRow(
|
||||
|
||||
Reference in New Issue
Block a user