You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
396 B
20 lines
396 B
package dorm
|
|
|
|
import (
|
|
"database/sql"
|
|
"github.com/uptrace/bun"
|
|
"github.com/uptrace/bun/dialect/pgdialect"
|
|
"github.com/uptrace/bun/driver/pgdriver"
|
|
)
|
|
|
|
func NewBunPgsqlClient(config *BunClientConfig) (*BunClient, error) {
|
|
|
|
c := &BunClient{config: config}
|
|
|
|
sqlDb := sql.OpenDB(pgdriver.NewConnector(pgdriver.WithDSN(c.config.Dns)))
|
|
|
|
c.Db = bun.NewDB(sqlDb, pgdialect.New())
|
|
|
|
return c, nil
|
|
}
|