//mongodb_dashboard func (d *MongoDb) CreateDashboard(dashboard *dashboard.Dashboard) (dashboard_id string, err error) { c := d.Session.DB(d.dbname).C(d.dashboards_c_name) dashboard.Id, err = common.GenId() if err != nil { return "", err } err = c.Insert(dashboard) return dashboard.Id, err }
//mongodb_dashboard func (d *MongoDb) CreateDashboardGroup(dgroup *dashboard.DashboardGroup) (dashboardgroup_id string, err error) { c := d.Session.DB(d.dbname).C(d.dashboard_groups_c_name) dgroup.Id, err = common.GenId() if err != nil { return "", err } err = c.Insert(dgroup) return dgroup.Id, err }
//mongodb_user func (d *MongoDb) CreateUser(user *utah.User) (user_id string, err error) { c := d.Session.DB(d.dbname).C(d.users_c_name) user.Id, err = common.GenId() if err != nil { return "", err } err = c.Insert(user) return user.Id, err }
func CreateNewMember(name string, mtype string) (m Member) { member_type := "general" if mtype != "" { member_type = mtype } new_id, _ := common.GenId() m.Id = new_id m.Name = name m.Type = member_type return m }
func CreateNewGroup(name string, gtype string) (g Group) { // default type: general //group_prop := s.GetProp group_type := "general" if gtype != "" { group_type = gtype } new_id, _ := common.GenId() g.Members = make([]Member, 0) g.Id = new_id g.Type = group_type g.Name = name return g }
func (d *MongoDb) CreateToken(userid string) (token_id string, err error) { _, err = d.GetUserById(userid) if err != nil { return "", err } token_id, err = common.GenId() if err != nil { return "", err } token := utah.Token{UserId: userid, Id: token_id} c := d.Session.DB(d.dbname).C(d.tokens_c_name) err = c.Insert(token) return token_id, err }