Introduce own Numeric type and revert to stdlib from pgx

This commit is contained in:
2021-12-02 21:29:44 +00:00
parent 6f8a94ff5d
commit 4646356b2d
16 changed files with 136 additions and 57 deletions

21
postgres/numeric.go Normal file
View File

@ -0,0 +1,21 @@
package postgres
import "github.com/jackc/pgtype"
type Numeric struct {
pgtype.Numeric
}
func (n Numeric) GetFloat64() float64 {
var balance float64
err := n.AssignTo(&balance)
if err != nil {
panic(err)
}
return balance
}
func (n Numeric) GetPositive() bool {
float := n.GetFloat64()
return float >= 0
}