26 lines
		
	
	
		
			417 B
		
	
	
	
		
			Go
		
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			417 B
		
	
	
	
		
			Go
		
	
	
	
package pkg
 | 
						|
 | 
						|
import (
 | 
						|
	"ai_scheduler/internal/config"
 | 
						|
	"ai_scheduler/internal/pkg/utils_gorm"
 | 
						|
 | 
						|
	"gorm.io/gorm"
 | 
						|
)
 | 
						|
 | 
						|
type Db struct {
 | 
						|
	Client *gorm.DB
 | 
						|
}
 | 
						|
 | 
						|
func NewGormDb(c *config.Config) (*Db, func()) {
 | 
						|
	transDBClient, mf := utils_gorm.DBConn(c.DB)
 | 
						|
	//directDBClient, df := directDB(c, hLog)
 | 
						|
	cleanup := func() {
 | 
						|
		mf()
 | 
						|
		//df()
 | 
						|
	}
 | 
						|
	return &Db{
 | 
						|
		Client: transDBClient,
 | 
						|
		//DirectDBClient: directDBClient,
 | 
						|
	}, cleanup
 | 
						|
}
 |