feat: gateway
This commit is contained in:
@@ -9,23 +9,25 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var (
|
||||
db *gorm.DB
|
||||
)
|
||||
|
||||
func initSqlite() {
|
||||
var err error
|
||||
godotenv.Load()
|
||||
|
||||
dbPath := conf.GetBotSettings().DBPath
|
||||
db, err := gorm.Open(sqlite.Open(dbPath), &gorm.Config{})
|
||||
db, err = gorm.Open(sqlite.Open(dbPath), &gorm.Config{})
|
||||
if err != nil {
|
||||
logrus.Panic(err, "Initializing DB Error")
|
||||
}
|
||||
CloseDB(db)
|
||||
logrus.Info("Initialized DB at ", dbPath)
|
||||
}
|
||||
|
||||
func GetSqlite() *gorm.DB {
|
||||
dbPath := conf.GetBotSettings().DBPath
|
||||
db, err := gorm.Open(sqlite.Open(dbPath), &gorm.Config{})
|
||||
if err != nil {
|
||||
return nil
|
||||
if db == nil {
|
||||
initSqlite()
|
||||
}
|
||||
return db
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user