fix: Removing hard coding

This commit is contained in:
Siwoo Jeon 2025-04-08 20:13:01 +09:00
parent 672fdbcaaf
commit e12b0416d4
Signed by: migan
GPG key ID: 036E9A8C5E8E48DA
3 changed files with 6 additions and 2 deletions

View file

@ -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()

View file

@ -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")

View file

@ -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")