// @Title update // @Description update // @Param id path string true "the objectid you want to get" // @Success 200 // @Failure 403 body is empty // @router /update/:id([0-9]+) [put] func (this *ManageController) Update() { o := orm.NewOrm() o.Using("default") // convert the string value to an int if articleId, err := strconv.Atoi(this.Ctx.Input.Param(":id")); err == nil { article := models.Article{Id: articleId} // attempt to load the record from the database if o.Read(&article) == nil { // set the Client and Url properties to arbitrary values article.Client = "Sitepoint" article.Url = "http://www.google.com" if _, err := o.Update(&article); err == nil { this.Data["json"] = "Record Was Updated." } } else { this.Data["json"] = "Record Was NOT Updated. Couldn't find article matching id" } } else { this.Data["json"] = "Record Was NOT Updated. Couldn't convert id from a string to a number. " + err.Error() } this.ServeJSON() }