MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / updateRelationCount

Method updateRelationCount

internal/repository/dao/relation.go:188–200  ·  view source on GitHub ↗

updateRelationCount 更新关注或粉丝计数器

(tx *gorm.DB, userID int64, field string, delta int64, timestamp int64)

Source from the content-addressed store, hash-verified

186
187// updateRelationCount 更新关注或粉丝计数器
188func (r *relationDAO) updateRelationCount(tx *gorm.DB, userID int64, field string, delta int64, timestamp int64) error {
189 return tx.Clauses(clause.OnConflict{
190 Columns: []clause.Column{{Name: "user_id"}},
191 DoUpdates: clause.Assignments(map[string]interface{}{
192 field: gorm.Expr(field+" + ?", delta),
193 "updated_at": timestamp,
194 }),
195 }).Create(&RelationCount{
196 UserID: userID,
197 CreatedAt: timestamp,
198 UpdatedAt: timestamp,
199 }).Error
200}

Callers 2

FollowUserMethod · 0.95
CancelFollowUserMethod · 0.95

Calls 1

CreateMethod · 0.65

Tested by

no test coverage detected