add IdFields (specifying head fields identifying a track) to container definition
This commit is contained in:
parent
18a1906967
commit
324c9b41c7
2 changed files with 24 additions and 16 deletions
|
@ -55,13 +55,13 @@ func StoreDB(db *sql.Storage, msg lib.Message) {
|
||||||
var container_definition *tracking.ContDef
|
var container_definition *tracking.ContDef
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
container_definition = &tracking.ContDef{
|
hf := lib.StrSlice{"domain", "action", "class", "item"}
|
||||||
|
ixs := []lib.StrSlice{hf}
|
||||||
|
ixs = append(ixs, lib.StrSlice{"domain", "class", "item"})
|
||||||
|
container_definition = (&tracking.ContDef{
|
||||||
ItemFactory: MakeMessage,
|
ItemFactory: MakeMessage,
|
||||||
TableName: "messages",
|
TableName: "messages",
|
||||||
HeadFields: []string{"domain", "action", "class", "item"},
|
HeadFields: hf,
|
||||||
Indexes: [][]string{
|
Indexes: ixs,
|
||||||
[]string{"domain", "action", "class", "item"},
|
}).SetUp()
|
||||||
[]string{"domain", "class", "item"},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,8 +80,16 @@ func (tr *Track) ScanP(rows *sql.Rows) error {
|
||||||
type ContDef struct {
|
type ContDef struct {
|
||||||
ItemFactory ItemFactory
|
ItemFactory ItemFactory
|
||||||
TableName string
|
TableName string
|
||||||
HeadFields []string
|
HeadFields lib.StrSlice
|
||||||
Indexes [][]string
|
IdFields lib.StrSlice
|
||||||
|
Indexes []lib.StrSlice
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cd *ContDef) SetUp() *ContDef {
|
||||||
|
if cd.IdFields == nil {
|
||||||
|
cd.IdFields = cd.HeadFields
|
||||||
|
}
|
||||||
|
return cd
|
||||||
}
|
}
|
||||||
|
|
||||||
type Container struct {
|
type Container struct {
|
||||||
|
@ -273,13 +281,13 @@ func (cont *Container) CreateTable() {
|
||||||
var container_definition *ContDef
|
var container_definition *ContDef
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
container_definition = &ContDef{
|
hf := lib.StrSlice{"taskId", "userName"}
|
||||||
|
ixs := []lib.StrSlice{hf}
|
||||||
|
ixs = append(ixs, lib.StrSlice{"userName"})
|
||||||
|
container_definition = (&ContDef{
|
||||||
ItemFactory: MakeTrack,
|
ItemFactory: MakeTrack,
|
||||||
TableName: "tracks",
|
TableName: "tracks",
|
||||||
HeadFields: []string{"taskId", "userName"},
|
HeadFields: hf,
|
||||||
Indexes: [][]string{
|
Indexes: ixs,
|
||||||
[]string{"taskId", "userName"},
|
}).SetUp()
|
||||||
[]string{"userName"},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue