本文整理汇总了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)
}