Files
kubeshark/api/pkg/database/main.go
gadotroee 0061f7d14a Add api build and clean to makefile (files restructure) (#9)
* no message
* add clean api command
2021-04-28 08:08:58 +03:00

26 lines
448 B
Go

package database
import (
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"mizuserver/pkg/models"
)
const (
DBPath = "./entries.db"
)
var (
DB = initDataBase(DBPath)
)
func GetEntriesTable() *gorm.DB {
return DB.Table("mizu_entries")
}
func initDataBase(databasePath string) *gorm.DB {
temp, _ := gorm.Open(sqlite.Open(databasePath), &gorm.Config{})
_ = temp.AutoMigrate(&models.MizuEntry{}) // this will ensure table is created
return temp
}