https://github.com/pgcontrib/bigint
bigint type for go-pg and other orms
https://github.com/pgcontrib/bigint
database golang orm postgresql
Last synced: 6 months ago
JSON representation
bigint type for go-pg and other orms
- Host: GitHub
- URL: https://github.com/pgcontrib/bigint
- Owner: pgcontrib
- License: gpl-3.0
- Created: 2021-07-19T13:47:29.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-08-18T10:54:57.000Z (almost 5 years ago)
- Last Synced: 2025-03-30T16:37:17.607Z (about 1 year ago)
- Topics: database, golang, orm, postgresql
- Language: Go
- Homepage:
- Size: 33.2 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bigint [](https://cloud.drone.io/pgcontrib/bigint) [](https://codecov.io/gh/pgcontrib/bigint) [](https://pkg.go.dev/github.com/pgcontrib/bigint)
**bigint** is a wrapper around math/big package to let us use big.int type in postgresql
In order to use big.Int structure into postgres database, one may thinks this is not straightforward and even painful.
In this package, we are going to solve it.
## math/big
This package uses math/big in its heart and extends its usefulnell even into postgres.
## Example use with go-pg
**go-pg** is an amazing orm for gophers to utilize postgres. This package is used to help **go-pg** users implement **math/big** functionalities.
```
import (
"net"
"github.com/pgcontrib/bigint"
"github.com/go-pg/pg/v10"
"github.com/go-pg/pg/v10/orm"
)
func main() {
type TableWithBigint struct {
Id uint64
tableName struct{} `pg:"table_with_bigint"`
Name string
Deposit *bigint.Bigint
}
db := pg.Connect(&pg.Options{
User: "user",
Password: "password",
Database: "testdb",
Addr: net.JoinHostPort(
"postgres-url",
"postgres-port",
),
})
err := db.Model((*TableWithBigint)(nil)).CreateTable(&orm.CreateTableOptions{
Temp: true,
FKConstraints: true,
IfNotExists: true,
})
if err != nil {
println(err)
}
}
```
# Support for [bun](https://github.com/uptrace/bun)
**bun** will be the successor of **go-pg** and this package is under development to cover it as well.