mirror of
https://github.com/getAlby/lndhub.go.git
synced 2026-01-19 21:05:45 +01:00
24 lines
492 B
Go
24 lines
492 B
Go
package database
|
|
|
|
import (
|
|
"github.com/bumi/lndhub.go/database/models"
|
|
"github.com/jinzhu/gorm"
|
|
_ "github.com/jinzhu/gorm/dialects/postgres"
|
|
_ "github.com/jinzhu/gorm/dialects/sqlite"
|
|
)
|
|
|
|
// Connect : Database connect
|
|
func Connect(database string) *gorm.DB {
|
|
//dsn := "host=localhost user=gorm password=gorm dbname=gorm port=9920 sslmode=disable"
|
|
db, err := gorm.Open(database, "./database/data.db")
|
|
db.LogMode(true)
|
|
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
models.Migrate(db)
|
|
|
|
return db
|
|
}
|