C
C#2mo ago
hosterip

Best way to delete all related things to a domain model

As an example there is a picture down below. On a picture there is admin model (one of domain models) there is subscription which can't exist without admin and subscription has some other things that can't exist without subscription. The question is where to delete them and how
No description
5 Replies
FestivalDelGelato
you either put a delete on the relationships in the database or when deleting from your service you search the data and delete it from the leaf to the root aggregate
hosterip
hosteripOP2mo ago
service meaning something like cqrs or service meaning it can be done in a repository?
FestivalDelGelato
by service i mean class, like a repository eventually the important part to me is that when you pick with a way to do this (so all in db or all in code) you stick with it also if you want to do this you have to pay attention with internal consistency, so that every time a delete touches these objects the behavior is always the same i would do this either with a layer or with a group of (abstract) queries that then are extended from the specific feature ("why are these objects being deleted?") it depends on the size of the project
hosterip
hosteripOP2mo ago
so shortly it means that I should enforce the same delete behavior across every use case in my project and use case could add some additional logic?
FestivalDelGelato
i only say you have to find a way to respect your model's constraints and having a univocal place where this happens is usually the easiest way to do it

Did you find this page helpful?