Skip to content

Why does user_repository have a direct dependency on gorm.DB? #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
AkashKarnatak opened this issue Oct 6, 2022 · 1 comment
Open

Comments

@AkashKarnatak
Copy link

In the file interface/repository/user_repository.go, struct userRepository has a direct dependency on gorm.DB which is defined in the outer layer and hence it violates the clean architecture principle.

// interface/repository/user_repository.go
type userRepository struct {
	db *gorm.DB
}
@manakuro
Copy link
Owner

Thanks for your question. Yes, you're right. Technically, the ORM should be defined as an adapter in order to follow the rule of specific technology separation, but if you feel that it’s too separated, then I think it’s fine to use it as is. Even if you change to another ORM in the future, then you only need to change the code in the repository at that time and you can still keep the dependencies between the usecase and the interface adapters. So, that depends on your team and projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants