Created
January 19, 2020 13:18
-
-
Save yutakahashi114/b7e3ee4778f8f7d71daa685b99701a05 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type countPerUserID struct { | |
Count uint | |
UserID uint64 | |
} | |
func (countPerUserID) TableName() string { | |
return "friends" | |
} | |
{ | |
cpuis := []countPerUserID{} | |
err = engine. | |
Select("count(*) as count, user_id"). | |
Where("deleted_at IS NULL"). | |
GroupBy("user_id"). | |
Find(&cpuis) | |
if err != nil { | |
log.Println(err) | |
return | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks for show this