-
Notifications
You must be signed in to change notification settings - Fork 9
/
engin_test.go
66 lines (49 loc) · 1.04 KB
/
engin_test.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package gorose
import (
"github.com/gohouse/t"
"testing"
)
type aaa t.MapStringT
func (u *aaa) TableName() string {
return "users"
}
//type bbb MapRows
type bbb []t.MapStringT
func (u *bbb) TableName() string {
return "users"
}
type UsersMap Data
func (*UsersMap) TableName() string {
return "users"
}
// 定义map多返回绑定表名,一定要像下边这样,单独定义,否则无法获取对应的 TableName()
type UsersMapSlice []Data
func (u *UsersMapSlice) TableName() string {
return "users"
}
type Users struct {
Uid int64 `orm:"uid"`
Name string `orm:"name"`
Age int64 `orm:"age"`
Fi string `orm:"ignore"`
}
func (Users) TableName() string {
return "users"
}
type Orders struct {
Id int `orm:"id"`
GoodsName string `orm:"goodsname"`
Price float64 `orm:"price"`
}
func TestEngin(t *testing.T) {
e := initDB()
e.SetPrefix("pre_")
t.Log(e.GetPrefix())
db := e.GetQueryDB()
err := db.Ping()
if err != nil {
t.Error("gorose初始化失败")
}
t.Log("gorose初始化成功")
t.Log(e.GetLogger())
}