コード例 #1
0
ファイル: comment.go プロジェクト: wangmingjob/goyangi
// UpdateLocationCommentCount updates location's comment count.
func UpdateLocationCommentCount(location *model.Location) (int, error) {
	location.CommentCount = db.ORM.Model(location).Association("Comments").Count()
	if db.ORM.Save(location).Error != nil {
		return http.StatusInternalServerError, errors.New("Location comment's count is not updated.")
	}
	return http.StatusOK, nil
}