-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Relationship between UserRepository
and TypeormRepositoryBase
#20
Comments
if (params.address?.country) {
where.country = params.address.country
} Keep in mind that this is an example implementation and might not be the best solution for all use cases. |
Thank you! To me it feels like in |
The problem is that mapper requires all (or almost all) fields to be present to save the entity, but in a query all fields are optional. Also a query may have different forms, not just simple ones like discussed here. Here is an example of a ...
if (status) {
receiver.status = status;
sender.status = status;
}
if (params?.createdBefore) {
receiver.createdAt = LessThanOrEqual(params.createdBefore);
sender.createdAt = LessThanOrEqual(params.createdBefore);
}
return [sender, receiver]; As you can see this would be impossible to map just by using a mapper, since you can have operators in your query like <= or >=, or you may need to query in a joined tables (like |
Ah, I see! Now I understand why one would want a more flexible way of preparing queries. My worry, however, is that this implementation suggests a generality that is not there. The repository exposes a method
where
To anyone who has not studied But when I call, say, My "solution" was to remove the |
That's right, you have to adjust either a type to accept only the parameters specified in |
While working through your database implementation, I was wondering why
UserRepository
does not useTypeormRepositoryBase.findOne
?domain-driven-hexagon/src/modules/user/database/user.repository.ts
Lines 35 to 43 in 0b55c3c
Shouldn't we do this instead:
And a second question: It seems like
UserRepository.prepareQuery
removes all query parameters except forid
? Why?domain-driven-hexagon/src/modules/user/database/user.repository.ts
Lines 61 to 70 in 0b55c3c
The text was updated successfully, but these errors were encountered: