-
Notifications
You must be signed in to change notification settings - Fork 4
/
db.go
49 lines (40 loc) · 921 Bytes
/
db.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package webizen
import (
"log"
"time"
_ "github.com/go-sql-driver/mysql"
"github.com/lunny/xorm"
)
type User struct {
Id int64
Uri string `xorm:"unique varbinary(500) not null"`
CreatedTime time.Time `xorm:"index created"`
UpdatedTime time.Time `xorm:"index updated"`
}
type UserName struct {
User int64 `xorm:"index"`
Name string `xorm:"index varchar(1000) not null"`
}
type UserImage struct {
User int64 `xorm:"index"`
Image string `xorm:"index varchar(1000) not null"`
}
type UserMbox struct {
User int64 `xorm:"index"`
Local string `xorm:"index varchar(1000) not null"`
Domain string `xorm:"index varchar(1000) not null"`
}
var (
db *xorm.Engine
)
func init() {
var err error
db, err = xorm.NewEngine("mysql", *dsn+"?charset=utf8&parseTime=True&autocommit=true")
if err != nil {
log.Panicln(err)
}
db.SetMaxIdleConns(4)
if *debug {
db.ShowSQL = true
}
}