Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7fa00f323f |
@@ -1,5 +1,7 @@
|
||||
package postgresql
|
||||
|
||||
// Wrapper around jackx/pgx pool
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
@@ -9,7 +11,18 @@ import (
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
)
|
||||
|
||||
func Connect(connStr string) (*pgxpool.Pool, error) {
|
||||
type Database struct {
|
||||
*pgxpool.Pool
|
||||
}
|
||||
|
||||
func NewDB(connStr string) *Database {
|
||||
db := &Database{}
|
||||
db.Connect(connStr)
|
||||
|
||||
return db
|
||||
}
|
||||
|
||||
func (db *Database) Connect(connStr string) (*pgxpool.Pool, error) {
|
||||
pool, err := pgxpool.New(context.Background(), connStr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user