G
G
gomerIT2021-10-16 00:00:07
JavaScript
gomerIT, 2021-10-16 00:00:07

Pattern Repository, when you need to pull data from 2 models - call two different repositories?

There are 2 tables in the database (users, user_profiles).
When calling the /api/users routing, you need to give json with information from 2 tables. How to correctly describe the repository in order to respect the pattern itself?
Describe 2 repositories - UserRepository, ProfileRepository and pull each in the services or create something similar to UserProfileRepository, but I'm thinking what if there are more than 2 connections in the database, then how to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2021-10-16
@gomerIT

From the point of view of this pattern, it does not matter how and where the data is stored, in 1 table or in general in different databases. Here the main question is whether, from the point of view of your domain area, user can exist as a full-fledged entity without a profile or not.
When you deal with this moment, the answer will come by itself, about how it is right in your case.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question