Skip to content

Commit

Permalink
fix: add postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
kooksee committed Jul 7, 2022
1 parent 6848d46 commit 50bfa97
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 3 deletions.
24 changes: 24 additions & 0 deletions clients/orm/driver/postgres/driver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package sqlite

import (
"errors"

"github.com/pubgo/xerror"
"gorm.io/driver/postgres"
"gorm.io/gorm"

"github.com/pubgo/lava/clients/orm"
"github.com/pubgo/lava/config"
"github.com/pubgo/lava/logging/logutil"
)

func init() {
orm.Register("postgres", func(cfg config.CfgMap) gorm.Dialector {
var dsn = cfg.GetString("dsn")
xerror.AssertFn(dsn == "", func() error {
logutil.Pretty(cfg)
return errors.New("dsn not found")
})
return postgres.Open(dsn)
})
}
10 changes: 9 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ require (
github.com/pubgo/funk v0.5.2
github.com/stretchr/testify v1.7.2
github.com/valyala/fasthttp v1.37.0
github.com/valyala/fasttemplate v1.2.1
gorm.io/driver/postgres v1.3.7
)

require (
Expand Down Expand Up @@ -133,6 +133,14 @@ require (
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/googleapis/gnostic v0.4.1 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.12.1 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.3.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
github.com/jackc/pgtype v1.11.0 // indirect
github.com/jackc/pgx/v4 v4.16.1 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand Down
Loading

0 comments on commit 50bfa97

Please sign in to comment.