Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repository method for adding relationships #56

Open
musjj opened this issue Jan 14, 2025 · 0 comments
Open

Repository method for adding relationships #56

musjj opened this issue Jan 14, 2025 · 0 comments

Comments

@musjj
Copy link

musjj commented Jan 14, 2025

My understanding of this is still a bit fuzzy, so sorry if I'm being confused. But, where should the repository method for adding a relationship belongs? For example, there's this domain logic:

public void addUser(User aUser) {
this.assertArgumentNotNull(aUser, "User must not be null.");
this.assertArgumentEquals(this.tenantId(), aUser.tenantId(), "Wrong tenant for this group.");
this.assertArgumentTrue(aUser.isEnabled(), "User is not enabled.");
if (this.groupMembers().add(aUser.toGroupMember()) && !this.isInternalGroup()) {
DomainEventPublisher
.instance()
.publish(new GroupUserAdded(
this.tenantId(),
this.name(),
aUser.username()));
}
}

But it looks like the handler for the GroupUserAdded event is not implemented yet. But if you want to persist the fact that this user is added to the group (as a group member), where would you put that method?

Would it be in the GroupRepository or UserRepository? Or maybe a new repository (e.g. GroupMemberRepository)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant