jeudi 7 janvier 2021

RepositoryPattern: Using various repositories to build ValueObjects

Description

I am writing a piece of software which uses various repositories. I use the repositories to query the database and build ValueObjects with the received data. My database is very relational:

Database Example

One foo has many bar, one bar has many baz, etc...

[
   {
      "foo1":{
         "bar1":{
            "baz1":[
               "..."
            ],
            "baz2":[
               "..."
            ],
            "baz3":[
               "..."
            ]
         },
         "bar2":{
            "baz4":[
               "..."
            ],
            "baz5":[
               "..."
            ],
            "baz6":[
               "..."
            ]
         }
      }
   }
]

Question

Is it "illegal" to call one repositories when building a ValueObject in another repository?

Note I know it can be done with one large query at the "head" of the relation (see it as a tree) but that would increase the bulk of the code by a ton and makes it harder to maintain on a global level.

Aucun commentaire:

Enregistrer un commentaire