Connecting to the datavase and adding the sql connection to our Repository
This commit is contained in:
		@ -4,10 +4,13 @@ import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"go-udemy-web-1/internal/config"
 | 
			
		||||
	"go-udemy-web-1/internal/driver"
 | 
			
		||||
	"go-udemy-web-1/internal/forms"
 | 
			
		||||
	"go-udemy-web-1/internal/helpers"
 | 
			
		||||
	"go-udemy-web-1/internal/models"
 | 
			
		||||
	"go-udemy-web-1/internal/render"
 | 
			
		||||
	"go-udemy-web-1/internal/repository"
 | 
			
		||||
	"go-udemy-web-1/internal/repository/dbrepo"
 | 
			
		||||
	"net/http"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@ -17,12 +20,14 @@ var Repo *Repository
 | 
			
		||||
// Repository is the repository type
 | 
			
		||||
type Repository struct {
 | 
			
		||||
	App *config.AppConfig
 | 
			
		||||
	DB  repository.DatabaseRepo
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewRepo creates a new repository
 | 
			
		||||
func NewRepo(a *config.AppConfig) *Repository {
 | 
			
		||||
func NewRepo(a *config.AppConfig, db *driver.DB) *Repository {
 | 
			
		||||
	return &Repository{
 | 
			
		||||
		App: a,
 | 
			
		||||
		DB:  dbrepo.NewPostgresRepo(db.SQL, a),
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user