You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if the transaction only handles one repository, you can use begin & comit, but if you need to perform transactions for more than one repository function, you can handle it in the usecase by defining a new repository transaction.
type (
UseCases interface{
ExampleImpl(context.Context)error
}
usecase struct{
repo Repositories
conn sqlx.DB
}
)
func NewUsecase()UseCases{
return &usecausecase{}
}
func(uc *usecase)ExampleImpl(context.Context)error{
//create begin from usecase.conn
// defer rollback
//call repository function
}`
`
I don't know if this method is clean or not, but at least it solves the problem.
No description provided.
The text was updated successfully, but these errors were encountered: