支持多个db

This commit is contained in:
liuchangshun 2024-03-06 17:36:54 +08:00
parent 8597d83657
commit af666aafa4

View File

@ -36,6 +36,14 @@ func GetDB(c *gin.Context, dbName ...string) *gorm.DB {
return DBS[d].WithContext(ctx)
}
func GetDB2(dbName ...string) *gorm.DB {
d := "one"
if len(dbName) != 0 {
d = dbName[0]
}
return DBS[d]
}
func InitDBS(env string, conf []DbConfig) {
DBS = map[string]*gorm.DB{}
if len(conf) == 1 {