Ejemplo n.º 1
0
// UpdateArticleCommentCount updates article's comment count.
func UpdateArticleCommentCount(article *model.Article) (int, error) {
	article.CommentCount = db.ORM.Model(article).Association("Comments").Count()
	if db.ORM.Save(article).Error != nil {
		return http.StatusInternalServerError, errors.New("Article comment's count is not updated.")
	}
	return http.StatusOK, nil
}