Skip to content

Instantly share code, notes, and snippets.

@dipeshhkc
Created April 26, 2021 11:58
Show Gist options
  • Save dipeshhkc/34d71ce8cc68510651eb724b4b706b6a to your computer and use it in GitHub Desktop.
Save dipeshhkc/34d71ce8cc68510651eb724b4b706b6a to your computer and use it in GitHub Desktop.
// WithTrx enables service with repository containing of transaction
func (u userService) WithTrx(trxHandle *gorm.DB) userService {
u.userRepository = u.userRepository.WithTrx(trxHandle)
return u
}
func (u userService) IncrementMoney(receiver uint, amount float64) error {
return u.userRepository.IncrementMoney(receiver, amount)
}
func (u userService) DecrementMoney(giver uint, amount float64) error {
return u.userRepository.DecrementMoney(giver, amount)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment