Skip to content

Repository method for adding relationships #56

@musjj

Description

@musjj

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)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions