Repository Pattern whith complementary objects (agregates)

by vivoconunxino   Last Updated August 10, 2018 10:05 AM

I have a table user and another table user_optionals related 1:1. The user_optionals are just a bunch of fields with some extra options set by the user.

This, in my app, is currently reflected by a User and a UserOptional models.

Thus I'm using the repository pattern, each one has it's own repo, UserRepository and UserOptionalRepository.

I'm a bit concerned of having to inject and handle two different repositories in my services since a UserOptional won't exist if its related User previously doesn't.

I've been reading, and seems to fit in a Domain Driven Development concept known as an Agregate, but still not sure how to deal whith it.

So I'm wondering if I should apply any pattern or methodology here which agrupates both. Maybe grouping both on a unique Model or creating a new repository composed by a UserRepository and a UserOptionalRepository, maybe I'm overthinking it...

Related Questions

Data Entities, Domain entities and the repositories

Updated February 23, 2018 20:05 PM