Example #1
0
//------Model CURD------//
// NewModel allocates and returns a new Model
func NewModel(router *Router) *Model {
	return &Model{
		Seeds:   []map[string]interface{}{},
		Columns: []*Column{},
		Set:     gset.NewSetThreadSafe(),
		router:  router,
	}
}
Example #2
0
//------Seeds and Set------//
// initSet adds all LineItem into Set, addUniqueValues and updateId
func (model *Model) initSet() {
	if model.Set == nil {
		model.Set = gset.NewSetThreadSafe()
	}
	for _, seed := range model.Seeds {
		li := NewLineItemWithMap(seed)
		model.Set.Add(li)
		model.addUniqueValues(li)
		model.updateId(li.ID())
	}
}