func Update(c *gin.Context) {
	db := c.MustGet("db").(*mgo.Database)

	article := models.Article{}
	err := c.Bind(&article)
	if err != nil {
		c.Error(err)
		return
	}

	query := bson.M{"_id": bson.ObjectIdHex(c.Param("_id"))}
	doc := bson.M{
		"title":      article.Title,
		"body":       article.Body,
		"updated_on": time.Now().UnixNano() / int64(time.Millisecond),
	}
	err = db.C(models.CollectionArticle).Update(query, doc)
	if err != nil {
		c.Error(err)
	}
	c.Redirect(http.StatusMovedPermanently, "/articles")
}
func Update(c *gin.Context) {
	db := c.MustGet("db").(*mgo.Database)

	article := models.Article{}
	err := c.Bind(&article)
	if err != nil {
		c.Error(err)
		return
	}

	query := bson.M{"_id": bson.ObjectIdHex(c.Param("_id"))}
	doc := bson.M{
		"title":      article.Title,
		"body":       article.Body,
		"updated_on": time.Now().UnixNano() / int64(time.Millisecond),
	}
	err = db.C(models.CollectionArticle).Update(query, doc)
	if err != nil {
		c.Error(err)
	}
	c.Redirect(http.StatusMovedPermanently, "/articles")
}
func Update ( c * gin . Context ) { db := c . MustGet ( " " ) . ( * mgo . Database ) article := models . Article { } err := c . Bind ( & article ) if err != nil { c . Error ( err ) return } query := bson . M { " " : bson . ObjectIdHex ( c . Param ( " " ) ) } doc := bson . M { " " : article . Title , " " : article . Body , " " : time . Now ( ) . UnixNano ( ) / int64 ( time . Millisecond ) , } err = db . C ( models . CollectionArticle ) . Update ( query , doc ) if err != nil { c . Error ( err ) } c . Redirect ( http . StatusMovedPermanently , " " ) }
// Update an article
Update an article