Connecting to the datavase and adding the sql connection to our Repository
This commit is contained in:
		
							
								
								
									
										19
									
								
								internal/repository/dbrepo/dbrepo.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								internal/repository/dbrepo/dbrepo.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
			
		||||
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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewPostgresRepo(conn *sql.DB, a *config.AppConfig) repository.DatabaseRepo {
 | 
			
		||||
	return &postgresDBRepo{
 | 
			
		||||
		App: a,
 | 
			
		||||
		DB:  conn,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										5
									
								
								internal/repository/dbrepo/postgres.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								internal/repository/dbrepo/postgres.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
			
		||||
package dbrepo
 | 
			
		||||
 | 
			
		||||
func (m *postgresDBRepo) AllUsers() bool {
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user