mirror of
https://github.com/aykhans/movier.git
synced 2025-07-17 16:04:02 +00:00
pgx.Conn -> pgxpool.Pool
This commit is contained in:
@@ -4,13 +4,15 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
// "github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
)
|
||||
|
||||
func NewDB(dbURL string) (*pgx.Conn, error) {
|
||||
conn, err := pgx.Connect(context.Background(), dbURL)
|
||||
func NewDB(dbURL string) (*pgxpool.Pool, error) {
|
||||
// conn, err := pgx.Connect(context.Background(), dbURL)
|
||||
dbpool, err := pgxpool.New(context.Background(), dbURL)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to connect to database: %w", err)
|
||||
}
|
||||
return conn, nil
|
||||
return dbpool, nil
|
||||
}
|
||||
|
@@ -4,15 +4,16 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
|
||||
"github.com/aykhans/movier/server/pkg/dto"
|
||||
)
|
||||
|
||||
type IMDbRepository struct {
|
||||
db *pgx.Conn
|
||||
db *pgxpool.Pool
|
||||
}
|
||||
|
||||
func NewIMDbRepository(db *pgx.Conn) *IMDbRepository {
|
||||
func NewIMDbRepository(db *pgxpool.Pool) *IMDbRepository {
|
||||
return &IMDbRepository{
|
||||
db: db,
|
||||
}
|
||||
|
Reference in New Issue
Block a user