summer_pr_task/vyatsuAPI/repository/pgsql.go
2024-07-06 09:13:03 +03:00

21 lines
334 B
Go

package repository
import (
"context"
"github.com/jackc/pgx/v5/pgxpool"
"sync"
)
type PGrepo struct {
mu sync.Mutex
pool *pgxpool.Pool
}
func New(connStr string) (*PGrepo, error) {
pool, err := pgxpool.New(context.Background(), connStr)
if err != nil {
panic(err)
}
return &PGrepo{mu: sync.Mutex{}, pool: pool}, nil
}