func (s *mySQLStore) UpdateFeature(feature *models.Feature) error { if err := meddler.Update(s.db, "feature", feature); err != nil { return err } envs, err := s.ListEnvironments() if err != nil { return err } envsByName := make(map[string]*models.Environment) for _, env := range envs { envsByName[env.Name] = env } stats, err := s.listStatusByFeatureID(feature.ID) if err != nil { return err } statusByEnvironmentID := make(map[int64]*status) for _, stat := range stats { statusByEnvironmentID[stat.EnvironmentID] = stat } for envName, enabled := range feature.Status { env := envsByName[envName] if env == nil { return ErrNoRows } stat := statusByEnvironmentID[env.ID] if stat == nil { err := s.createStatus(&status{ FeatureID: feature.ID, EnvironmentID: env.ID, Enabled: enabled, }) if err != nil { return err } } else { if stat.Enabled == enabled { // no changes continue } stat.Enabled = enabled err := s.updateStatus(stat) if err != nil { return err } } } return nil }
func (sr *SQL) Update(r *Request, rec *Record) error { lp, psql := sr.GetPromise(r) defer lp.Release() if rec.Attributes != nil { SetId(rec.Attributes, rec.Id) } else { // TODO: should this panic? is it possible to UPDATE with a nil ID? } tx, err := psql.GetSQLTransaction(sr.DB) if err != nil { return err } r.API.Logger.Debugf("Fields: %#v\n", rec.Attributes) return meddler.Update(tx, sr.Table, rec.Attributes) }
func (db *buildstore) Update(build *model.Build) error { return meddler.Update(db, buildTable, build) }
func (db *datastore) UpdateUser(user *model.User) error { return meddler.Update(db, userTable, user) }
func (s *mySQLStore) updateStatus(status *status) error { return meddler.Update(s.db, "feature_status", status) }
func (s *mySQLStore) UpdateEnvironment(environment *models.Environment) error { return meddler.Update(s.db, "environment", environment) }
// PutUser saves a user in the datastore. func (db *Userstore) PutUser(user *model.User) error { user.Updated = time.Now().UTC().Unix() return meddler.Update(db, userTable, user) }
func (db *repostore) Update(repo *model.Repo) error { return meddler.Update(db, repoTable, repo) }
func (db *nodestore) Update(node *model.Node) error { return meddler.Update(db, nodeTable, node) }
func (db *jobstore) Update(job *model.Job) error { return meddler.Update(db, jobTable, job) }
func (u *User) UpdateBalance(db meddler.DB, delta int) error { u.Balance += delta return meddler.Update(db, "users", u) }
func (db *datastore) UpdateAgent(agent *model.Agent) error { return meddler.Update(db, agentTable, agent) }