fix: Removing hard coding
This commit is contained in:
parent
672fdbcaaf
commit
e12b0416d4
3 changed files with 6 additions and 2 deletions
|
@ -23,6 +23,7 @@ type MuffinConfig struct {
|
|||
Bot botConfig
|
||||
Train trainConfig
|
||||
DatabaseURL string
|
||||
DBName string
|
||||
}
|
||||
|
||||
func loadConfig() *MuffinConfig {
|
||||
|
@ -57,6 +58,7 @@ func setConfig(config *MuffinConfig) {
|
|||
config.Train.UserID = getValue("TRAIN_USER_ID")
|
||||
|
||||
config.DatabaseURL = getRequiredValue("DATABASE_URL")
|
||||
config.DBName = getRequiredValue("DATABASE_NAME")
|
||||
}
|
||||
|
||||
var Config *MuffinConfig = loadConfig()
|
||||
|
|
|
@ -3,6 +3,7 @@ package databases
|
|||
import (
|
||||
"time"
|
||||
|
||||
"git.wh64.net/muffin/goMuffin/configs"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
"go.mongodb.org/mongo-driver/v2/mongo"
|
||||
)
|
||||
|
@ -22,4 +23,4 @@ type Learn struct {
|
|||
CreatedAt time.Time `bson:"created_at"`
|
||||
}
|
||||
|
||||
var Learns *mongo.Collection = Client.Database("muffin_ai_test").Collection("learn")
|
||||
var Learns *mongo.Collection = Client.Database(configs.Config.DBName).Collection("learn")
|
||||
|
|
|
@ -3,6 +3,7 @@ package databases
|
|||
import (
|
||||
"time"
|
||||
|
||||
"git.wh64.net/muffin/goMuffin/configs"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
"go.mongodb.org/mongo-driver/v2/mongo"
|
||||
)
|
||||
|
@ -20,4 +21,4 @@ type Text struct {
|
|||
CreatedAt time.Time `bson:"created_at"`
|
||||
}
|
||||
|
||||
var Texts *mongo.Collection = Client.Database("muffin_ai_test").Collection("text")
|
||||
var Texts *mongo.Collection = Client.Database(configs.Config.DBName).Collection("text")
|
||||
|
|
Loading…
Reference in a new issue