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
|
||||
|
||||
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,
|
||||
TableName: "messages",
|
||||
HeadFields: []string{"domain", "action", "class", "item"},
|
||||
Indexes: [][]string{
|
||||
[]string{"domain", "action", "class", "item"},
|
||||
[]string{"domain", "class", "item"},
|
||||
},
|
||||
}
|
||||
HeadFields: hf,
|
||||
Indexes: ixs,
|
||||
}).SetUp()
|
||||
}
|
||||
|
|
|
@ -80,8 +80,16 @@ func (tr *Track) ScanP(rows *sql.Rows) error {
|
|||
type ContDef struct {
|
||||
ItemFactory ItemFactory
|
||||
TableName string
|
||||
HeadFields []string
|
||||
Indexes [][]string
|
||||
HeadFields lib.StrSlice
|
||||
IdFields lib.StrSlice
|
||||
Indexes []lib.StrSlice
|
||||
}
|
||||
|
||||
func (cd *ContDef) SetUp() *ContDef {
|
||||
if cd.IdFields == nil {
|
||||
cd.IdFields = cd.HeadFields
|
||||
}
|
||||
return cd
|
||||
}
|
||||
|
||||
type Container struct {
|
||||
|
@ -273,13 +281,13 @@ func (cont *Container) CreateTable() {
|
|||
var container_definition *ContDef
|
||||
|
||||
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,
|
||||
TableName: "tracks",
|
||||
HeadFields: []string{"taskId", "userName"},
|
||||
Indexes: [][]string{
|
||||
[]string{"taskId", "userName"},
|
||||
[]string{"userName"},
|
||||
},
|
||||
}
|
||||
HeadFields: hf,
|
||||
Indexes: ixs,
|
||||
}).SetUp()
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue