Keeping logic of your application along with your database logic makes your application much more complex, hard to test, and maintain.
There is already a proven and simple pattern that solves these issues. The pattern that allows you to separate your application logic from database logic. It allows you to make your code simpler and easier to add new functionalities.
This is not just another article with random code snippets.
This post is part of a bigger series where we show how to build Go applications that are easy to develop, maintain, and fun to work with in the long term. We are doing it by sharing proven techniques based on many experiments we did with teams we lead and scientific research.
So it is better to move the database logic out of repositories layer into adapters, like in the trainer example.
Description
As per The Repository Pattern
So it is better to move the database logic out of
repositories
layer into adapters, like in the trainer example.Additional Information
No response