Introduce own Numeric type and revert to stdlib from pgx
This commit is contained in:
@ -1,12 +1,10 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"embed"
|
||||
"fmt"
|
||||
|
||||
"github.com/jackc/pgx/v4"
|
||||
_ "github.com/jackc/pgx/v4/stdlib"
|
||||
"github.com/pressly/goose/v3"
|
||||
)
|
||||
@ -27,12 +25,7 @@ func Connect(server string, user string, password string, database string) (*Que
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
connPG, err := pgx.Connect(context.Background(), connString)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return New(connPG), conn, nil
|
||||
return New(conn), conn, nil
|
||||
}
|
||||
|
||||
func (tx Transaction) GetAmount() float64 {
|
||||
@ -62,3 +55,17 @@ func (tx GetTransactionsForBudgetRow) GetPositive() bool {
|
||||
amount := tx.GetAmount()
|
||||
return amount >= 0
|
||||
}
|
||||
|
||||
func (tx GetAccountsWithBalanceRow) GetBalance() float64 {
|
||||
var balance float64
|
||||
err := tx.Balance.AssignTo(&balance)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return balance
|
||||
}
|
||||
|
||||
func (tx GetAccountsWithBalanceRow) GetPositive() bool {
|
||||
balance := tx.GetBalance()
|
||||
return balance >= 0
|
||||
}
|
||||
|
Reference in New Issue
Block a user