30 lines
470 B
Go
30 lines
470 B
Go
package db_cold
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gorm.io/driver/sqlite"
|
|
"gorm.io/gorm"
|
|
"zomo.dev/largehadroncollider/util"
|
|
)
|
|
|
|
// sqlite file
|
|
|
|
func InitDBColdConn(conf *util.Config) (*DBColdConn, error) {
|
|
db, err := gorm.Open(sqlite.Open(conf.SQliteDB), &gorm.Config{})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ctx := context.Background()
|
|
|
|
cold := &DBColdConn{ db, ctx }
|
|
cold.initUserAuth()
|
|
|
|
return cold, nil
|
|
}
|
|
|
|
type DBColdConn struct {
|
|
Gorm *gorm.DB
|
|
Ctx context.Context
|
|
}
|