Skip to content

Commit

Permalink
clear sub before appending
Browse files Browse the repository at this point in the history
  • Loading branch information
rupinr committed Oct 29, 2024
1 parent a6e4a81 commit 20eeb1d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,18 @@ func CreateSubscription(user entity.User, sites []string, subscriptionScheduleID

tx.Where(entity.Subscription{
UserID: user.ID,
}).Assign(values).FirstOrCreate(&subscription).Association("Sites").Append(foundSites)
}).Find(&subscription)

tx.Model(&subscription).
Association("Sites").
Clear()

tx.Where(entity.Subscription{
UserID: user.ID,
}).Assign(values).
FirstOrCreate(&subscription).
Association("Sites").
Append(foundSites)
return nil
})
return subscription
Expand Down

0 comments on commit 20eeb1d

Please sign in to comment.