本文整理匯總了Golang中github.com/russross/meddler.Update函數的典型用法代碼示例。如果您正苦於以下問題:Golang Update函數的具體用法?Golang Update怎麽用?Golang Update使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Update函數的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: UpdateFeature
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
}
示例2: Update
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)
}
示例3: Update
func (db *buildstore) Update(build *model.Build) error {
return meddler.Update(db, buildTable, build)
}
示例4: UpdateUser
func (db *datastore) UpdateUser(user *model.User) error {
return meddler.Update(db, userTable, user)
}
示例5: updateStatus
func (s *mySQLStore) updateStatus(status *status) error {
return meddler.Update(s.db, "feature_status", status)
}
示例6: UpdateEnvironment
func (s *mySQLStore) UpdateEnvironment(environment *models.Environment) error {
return meddler.Update(s.db, "environment", environment)
}
示例7: PutUser
// 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)
}
示例8: Update
func (db *repostore) Update(repo *model.Repo) error {
return meddler.Update(db, repoTable, repo)
}
示例9: Update
func (db *nodestore) Update(node *model.Node) error {
return meddler.Update(db, nodeTable, node)
}
示例10: Update
func (db *jobstore) Update(job *model.Job) error {
return meddler.Update(db, jobTable, job)
}
示例11: UpdateBalance
func (u *User) UpdateBalance(db meddler.DB, delta int) error {
u.Balance += delta
return meddler.Update(db, "users", u)
}
示例12: UpdateAgent
func (db *datastore) UpdateAgent(agent *model.Agent) error {
return meddler.Update(db, agentTable, agent)
}