Reputation: 2567
I have an aggregateRoot named Project.
This project can have a sub-entity named GitRepository. This Entity represents access to a external git repository (like Github, Bitbucket).
Here's an example of how should look my persisted data (I use NoSql DB):
Project {
id: String
name: String
GitRepository: GitRepository {
externalRepoId: String // e.g. reference to the external github repo ID
externalToken: String
}
The GitRepository Entity contain properties that allow me to retrieve more data from such external service (for instance repository name or collaborators).
The thing I don't understand when I have external reference is how the aggregate root should be stored (I guess I should store the external ID references of Github). But then how I can create my complete AR that fill the data (collaborators, repository name, ...).
Here's an example of how my Aggregate root should look once data are fetched from external service.
Project {
id: String
name: String
gitRepository {
externalRepoId: String
externalToken: String
repoName: String
collaborators: List []
repoCreatedAt: Date
...
}
}
PS: An other option is to duplicate the data and store every informations I can get from Github, but in that case I can have inconsistencies (if the user update its data on external service)
Upvotes: 1
Views: 622
Reputation: 9479
I would really consider whether the external repository is a different aggregate root than the internal one. I know it seems ideologically simpler to say they are the same thing, but they clearly are not. The idea of a "Complete AR" for your project shouldn't include things that can be changed outside of your application. Create a separate AR for your external repo and I think most of your problems will go away.
Upvotes: 2