2024-07-06 20:55:25 +00:00
|
|
|
package dbrepo
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
"go-udemy-web-1/internal/config"
|
|
|
|
"go-udemy-web-1/internal/repository"
|
|
|
|
)
|
|
|
|
|
|
|
|
type postgresDBRepo struct {
|
|
|
|
App *config.AppConfig
|
|
|
|
DB *sql.DB
|
|
|
|
}
|
|
|
|
|
2024-07-12 20:43:16 +00:00
|
|
|
type testDBRepo struct {
|
|
|
|
App *config.AppConfig
|
|
|
|
DB *sql.DB
|
|
|
|
}
|
|
|
|
|
2024-07-06 20:55:25 +00:00
|
|
|
func NewPostgresRepo(conn *sql.DB, a *config.AppConfig) repository.DatabaseRepo {
|
|
|
|
return &postgresDBRepo{
|
|
|
|
App: a,
|
|
|
|
DB: conn,
|
|
|
|
}
|
|
|
|
}
|
2024-07-12 20:43:16 +00:00
|
|
|
|
|
|
|
func NewTestingRepo(a *config.AppConfig) repository.DatabaseRepo {
|
|
|
|
return &testDBRepo{
|
|
|
|
App: a,
|
|
|
|
}
|
|
|
|
}
|