Usually, we start building the Domain Fisical Representation from The Query Point of View. One particular characteristic of RECQ Architecture is the application of the Database-per-query pattern where you design entire databases only to fulfil a Query most efficiently. In order to do that we need to explore all the Queries to define indexes and database paradigms that handle better the request and analyse Views to define the required fields.
Model
In this tutorial, we have chosen to use Spring Data JPA and a relational database to store objects, but we are gonna to implement the Document Paradigm to represent OneToMany Relations.
So, we can start defining the Todo object and inside of it the mapper method toView() that returns the Entity as RECQ View Payload:
Once the model is properly implemented, we can define the Repository to access database Data and also adding specific methods to answer the proper Queries.
importorg.springframework.data.domain.Page;importorg.springframework.data.domain.PageRequest;importorg.springframework.data.domain.Pageable;importorg.springframework.data.jpa.repository.JpaRepository;importorg.springframework.data.jpa.repository.Query;publicinterfaceTodoListRepositoryextendsJpaRepository<TodoList,String> { @Query("select t from TodoList t where t.name like ?1")Page<TodoList> search(String query,Pageable pageable);}