Change to multiple db connection
This commit is contained in:
1 parent
313bcabbae
commit
5b349bf1b7
4 files changed
+198
-10
No files matched your search
+4
-4
@@ -3,13 +3,13 @@ package bd
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v4/pgxpool"
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
type Bd struct {
|
||||
config *ConfigBD
|
||||
db *pgx.Conn
|
||||
db *pgxpool.Pool
|
||||
filmsrepo *Filmsrepo
|
||||
siriesrepo *Siriesrepo
|
||||
userrepo *Userrepo
|
||||
@@ -22,7 +22,7 @@ func New(config *ConfigBD) *Bd {
|
||||
}
|
||||
|
||||
func (b *Bd) Open() error {
|
||||
db, err := pgx.Connect(context.Background(), NewConfig().BaseUrlBd)
|
||||
db, err := pgxpool.Connect(context.Background(), NewConfig().BaseUrlBd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -34,7 +34,7 @@ func (b *Bd) Open() error {
|
||||
}
|
||||
|
||||
func (b *Bd) Close() {
|
||||
b.db.Close(context.Background())
|
||||
b.db.Close()
|
||||
}
|
||||
|
||||
func (b *Bd) Films() *Filmsrepo {
|
||||
|
||||
Reference in new issue
Block a user