From 77f6580702a3bf1f246f21ff314bdf2bac4ead78 Mon Sep 17 00:00:00 2001 From: caibin Date: Sat, 7 May 2022 15:47:54 +0800 Subject: [PATCH] fix count error --- model/schema.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model/schema.go b/model/schema.go index 229c7e7..60f65c4 100644 --- a/model/schema.go +++ b/model/schema.go @@ -62,8 +62,8 @@ func GetChaincodeNameByChannelId(channelId int) ([]string, error) { func CountChaincodeByChannelId(channelId int) (int64, error) { var count int64 - err := db.Table("schema").Select("count(chaincode_name)"). - Where("channel_id = ?", channelId).Group("chaincode_name"). + err := db.Table("schema").Select("count(distinct(chaincode_name))"). + Where("channel_id = ?", channelId). Find(&count).Error if err != nil { logger.WithField("error", err).Error("failed to get count of chaincode")