moving insert to another model and done so in database internal

This commit is contained in:
samantha42
2026-03-25 21:58:08 +01:00
parent 2dccca5da1
commit d491b9c14c
11 changed files with 85 additions and 83 deletions

View File

@@ -36,7 +36,7 @@ func GetTrades(db *sql.DB) ([]model.Trade, error) {
if err != nil {
return nil, err
}
t.Currency = currency
t.Currency = currency.Name
t.Ticker = *company
switch TypeInt {
case 0:
@@ -83,7 +83,7 @@ func InsertTrade(db *sql.DB, trade model.Trade) error {
_, err := db.Exec(
"INSERT INTO trades (company_id, currency_id, shares, product, type, price, traded_at) VALUES (?, ?, ?, ?, ?, ?, ?)",
trade.Ticker.ID,
trade.Currency.ID,
trade.Currency,
trade.Shares,
trade.Product,
trade.Type,