File tree Expand file tree Collapse file tree 3 files changed +104
-3
lines changed
clients/orm/driver/postgres Expand file tree Collapse file tree 3 files changed +104
-3
lines changed Original file line number Diff line number Diff line change 1+ package sqlite
2+
3+ import (
4+ "errors"
5+
6+ "github.com/pubgo/xerror"
7+ "gorm.io/driver/postgres"
8+ "gorm.io/gorm"
9+
10+ "github.com/pubgo/lava/clients/orm"
11+ "github.com/pubgo/lava/config"
12+ "github.com/pubgo/lava/logging/logutil"
13+ )
14+
15+ func init () {
16+ orm .Register ("postgres" , func (cfg config.CfgMap ) gorm.Dialector {
17+ var dsn = cfg .GetString ("dsn" )
18+ xerror .AssertFn (dsn == "" , func () error {
19+ logutil .Pretty (cfg )
20+ return errors .New ("dsn not found" )
21+ })
22+ return postgres .Open (dsn )
23+ })
24+ }
Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ require (
9696 github.com/pubgo/funk v0.5.2
9797 github.com/stretchr/testify v1.7.2
9898 github.com/valyala/fasthttp v1.37.0
99- github.com/valyala/fasttemplate v1.2.1
99+ gorm.io/driver/postgres v1.3.7
100100)
101101
102102require (
@@ -133,6 +133,14 @@ require (
133133 github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
134134 github.com/googleapis/gnostic v0.4.1 // indirect
135135 github.com/imdario/mergo v0.3.12 // indirect
136+ github.com/jackc/chunkreader/v2 v2.0.1 // indirect
137+ github.com/jackc/pgconn v1.12.1 // indirect
138+ github.com/jackc/pgio v1.0.0 // indirect
139+ github.com/jackc/pgpassfile v1.0.0 // indirect
140+ github.com/jackc/pgproto3/v2 v2.3.0 // indirect
141+ github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
142+ github.com/jackc/pgtype v1.11.0 // indirect
143+ github.com/jackc/pgx/v4 v4.16.1 // indirect
136144 github.com/jinzhu/inflection v1.0.0 // indirect
137145 github.com/jinzhu/now v1.1.5 // indirect
138146 github.com/josharian/intern v1.0.0 // indirect
You can’t perform that action at this time.
0 commit comments