databoard-transform/database.go
2020-12-09 17:43:47 +08:00

41 lines
849 B
Go

package main
import (
"time"
"github.com/go-xorm/xorm"
)
// Database mysql数据结构
type Database struct {
engine *xorm.Engine
T struct {
CountLiveAnchors *xorm.Session
}
}
// 默认全局的数据库对象
var db *Database
func databaseInit() {
db := &Database{}
// 初始化数据myrocks驱动链接
engine, err := xorm.NewEngine("mysql", "root:Nono-databoard@tcp(127.0.0.1:3306)/databoard?parseTime=true&loc=Local&charset=utf8&collation=utf8_unicode_ci")
if err != nil {
panic(err)
}
db.engine = engine
// 数据库表对象
db.T.CountLiveAnchors = engine.Table("count_live_anchors")
}
// CountLiveAnchors count_live_anchors
type CountLiveAnchors struct {
UID string `xorm:"uid"`
CreateAt time.Time `xorm:"create_at"`
IsCounted int `xorm:"is_counted"`
CountMap string `xorm:"count_map"`
}