DEV Community

Discussion on: Clean Architecture using Golang

Collapse
 
chidiwilliams profile image
Chidi Williams

Thanks for your article.

From this implementation, the service only utilizes one Repository. What do I do if I have two different databases (maybe, Mongo as main storage and Elastic for search)? How would I create and use a service that would have getUsers() (Mongo) and searchUser() (Elastic)?

Collapse
 
eminetto profile image
Elton Minetto

Here your service can receive over one Repository. One implemented using Mongo (userRepo) and other using Elastic (userSearch):

userService := user.NewService(userRepo, userSearch, queueService)

I think this could be a valid solution