init.go
753 Bytes
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
package models
import (
"pro2d/components/db"
"pro2d/protos/pb"
"pro2d/utils"
)
func InitDoc(schema ...interface{}) {
for _, s := range schema {
for coll, key := range utils.FindIndex(s) {
if err := db.CreateCollection(coll); err != nil {
continue
}
utils.Sugar.Debugf("InitDoc collect: %v, createIndex: %s", coll, key)
res, err := db.SetUnique(coll, key)
if err != nil {
utils.Sugar.Errorf("InitDoc unique: %s, err: %v", res, err)
continue
}
}
}
}
func InitAccountServerModels() {
var schema []interface{} = []interface{}{
pb.AccountInfo{},
}
InitDoc(schema...)
}
func InitGameServerModels() {
var schema []interface{} = []interface{}{
pb.Hero{},
pb.Role{},
pb.Team{},
}
InitDoc(schema...)
}