Rewired db connection to store/rdbms
This commit is contained in:
+12
-4
@@ -18,8 +18,17 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func New(ctx context.Context, dsn string) (s *Store, err error) {
|
||||
var cfg *rdbms.Config
|
||||
func init() {
|
||||
store.Register(Connect, "postgresql", "postgres", "pgsql")
|
||||
}
|
||||
|
||||
func Connect(ctx context.Context, dsn string) (store.Storable, error) {
|
||||
var (
|
||||
err error
|
||||
cfg *rdbms.Config
|
||||
|
||||
s = new(Store)
|
||||
)
|
||||
|
||||
if cfg, err = ProcDataSourceName(dsn); err != nil {
|
||||
return nil, err
|
||||
@@ -30,8 +39,7 @@ func New(ctx context.Context, dsn string) (s *Store, err error) {
|
||||
cfg.SqlFunctionHandler = sqlFunctionHandler
|
||||
cfg.CastModuleFieldToColumnType = fieldToColumnTypeCaster
|
||||
|
||||
s = new(Store)
|
||||
if s.Store, err = rdbms.New(ctx, cfg); err != nil {
|
||||
if s.Store, err = rdbms.Connect(ctx, cfg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user