add trade and position service
This commit is contained in:
@@ -43,9 +43,9 @@ func GetTrades(db *sql.DB) ([]model.Trade, error) {
|
||||
}
|
||||
|
||||
func GetPositions(db *sql.DB) ([]model.Position, error) {
|
||||
rows, err := db.Query("SELECT company_id, symbol, shares, weight, CostBasis, currency_id, currency_code from position")
|
||||
rows, err := db.Query("SELECT company_id, symbol, shares, weight, cost_basis, currency_id, currency_code from position")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return []model.Position{}, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
@@ -55,13 +55,13 @@ func GetPositions(db *sql.DB) ([]model.Position, error) {
|
||||
|
||||
err := rows.Scan(&t.CompanyID, &t.Symbol, &t.Shares, &t.Weight, &t.CostBasis, &t.CurrencyID, &t.CurrencyCode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return []model.Position{}, err
|
||||
}
|
||||
|
||||
positions = append(positions, t)
|
||||
}
|
||||
if err = rows.Err(); err != nil {
|
||||
return nil, err
|
||||
return []model.Position{}, err
|
||||
}
|
||||
|
||||
return positions, nil
|
||||
|
||||
Reference in New Issue
Block a user