invalid db.go

This commit is contained in:
Dikiy13371 2025-10-07 23:34:07 +03:00
parent 1aad1ef359
commit d457c5a9d0

View file

@ -121,9 +121,8 @@ func isTableEmpty(tableName string) (bool, error) {
// InitDB sets up the database connection, migrates models, and runs seeders. // InitDB sets up the database connection, migrates models, and runs seeders.
func InitDB(dbPath string) error { func InitDB(dbPath string) error {
dir := path.Dir(dbPath) dir := path.Dir(dbPath)
err := os.MkdirAll(dir, fs.ModePerm) if err := os.MkdirAll(dir, fs.ModePerm); err != nil { return err }
if err != nil { // ...
return err
} }
var gormLogger logger.Interface var gormLogger logger.Interface
@ -170,9 +169,7 @@ func CloseDB() error {
} }
// GetDB returns the global GORM database instance. // GetDB returns the global GORM database instance.
func GetDB() *gorm.DB { func GetDB() *gorm.DB { return db }
return db
}
// IsNotFound checks if the given error is a GORM record not found error. // IsNotFound checks if the given error is a GORM record not found error.
func IsNotFound(err error) bool { func IsNotFound(err error) bool {