支持多个db
This commit is contained in:
parent
8597d83657
commit
af666aafa4
@ -36,6 +36,14 @@ func GetDB(c *gin.Context, dbName ...string) *gorm.DB {
|
|||||||
return DBS[d].WithContext(ctx)
|
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) {
|
func InitDBS(env string, conf []DbConfig) {
|
||||||
DBS = map[string]*gorm.DB{}
|
DBS = map[string]*gorm.DB{}
|
||||||
if len(conf) == 1 {
|
if len(conf) == 1 {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user