Let’s use the classic blog context example. In our domain we have the following scenarios: Userscan write Posts. Postsmust be cataloged in at least one Category. Postscan be described using Tags. Userscan comment Posts.
Four sites ( Post, Category, Tag, Comment) are implemented as separate units because of the fact that I did not find any rule to the data entities intervened in the other. So, for each aggregate, I will have one repository that represents it. In addition, each population refers to others by its identifier.
Following CQRS, this script I read typical use cases that lead to commands such as WriteNewPostCommand, PublishPostCommand, DeletePostCommand, etc. along with their respective queries for retrieving data from repositories. FindPostByIdQuery, FindTagByTagNameQuery, FindPostsByAuthorIdQueryEtc.
Depending on which site of the application we are on (backend or front), we will have more or less complex requests. So, if we are on the first page, we may need to create some widgets in order to receive the latest comments, the last message of the category, etc. Queries that include a simple object Query(several search criteria) and QueryHandlervery simple (one repository as a dependency on the handler class)
But elsewhere, these queries may be more complex. In the admin panel, we need to show in the table a relationship that satisfies complex search criteria. There may be interesting search messages: author’s name (without identifier), category names, tag name, publication date ... A criterion that applies to different aggregates and different repositories.
In addition, in our message table, we do not want to display the message along with the author ID or category identifier. We need to show all the information (username, avatar, category name, category icon, etc.).
My questions:
, , (findAll, findById, findByCriterias...) , ? , a findPostById(uuid) findPostByCustomFilter(filter), post , , , ? - , , ?
, 12/12/2014, , "" "" "sci-fi" "adventure", , Query QueryHandler?
a) Query (authorName, categoriesNames, TagsNames, User, Category, Tag ), QueryHandler . ...
b) Queries (FindCategoryByName, FindTagByName, FindUserByName), -
FindPostQuery, authorid, categoryid, tagid, ?
b) , .