I'm trying to figure out how to define these owner/member relationships in my Neo4j.rb Active::Node models.
- Users can create many teams (and become the "owner" of those teams)
- Users can fetch the teams that they have created
- Teams have a single owner (user) and many members (other users)
- Owners can add other users as members to a team
- Users can fetch all teams that they are either an owner or a member of
So far I have something like this, but it isn't working right and I am totally lost.
class User
include Neo4j::ActiveNode
has_many :out, :my_teams, model_class: 'Team'
end
class Team
include Neo4j::ActiveNode
property :name, type: String
has_one :in, :owner, model_class: 'User'
end
user = create(:user)
team = build(:team)
user.my_teams << team
expect(team.owner).to eq user