Introduce own Numeric type and revert to stdlib from pgx
This commit is contained in:
21
postgres/numeric.go
Normal file
21
postgres/numeric.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user