feat: service/controller prototype
This commit is contained in:
18
backend/internal/utils/db.go
Normal file
18
backend/internal/utils/db.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"context"
|
||||
"easywish/config"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
)
|
||||
|
||||
func GetDbConn() (*pgx.Conn, context.Context, error) {
|
||||
ctx := context.Background()
|
||||
conn, err := pgx.Connect(ctx, config.GetConfig().DatabaseUrl)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return conn, ctx, nil
|
||||
}
|
||||
Reference in New Issue
Block a user