mardi 21 avril 2020

Can we have models who depends on each other?

class Parent {
    long id;
    List<Child> children;   
}

class Child {
    long id;
    Parent parent;
}

GET /parents/1, here have to show children of Parent 1

GET /children/101 here have to show Parent of Child 101

I actually didnt like above circular dependency design, but I am not understanding how to fix above scenario. Need some help to fix above design issue.

And also iam not sure whether can we have DTOs who depends on each other? Is this correct design?

Aucun commentaire:

Enregistrer un commentaire