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

Maximum Number of Relationships #352

Closed
ghost opened this issue Jul 2, 2018 · 1 comment
Closed

Maximum Number of Relationships #352

ghost opened this issue Jul 2, 2018 · 1 comment

Comments

@ghost
Copy link

ghost commented Jul 2, 2018

It would be nice to define the number of relationships that can exist between two types of nodes. Not only for uniqueness, but also for logic.

class Sedan(StructuredNode):
    seat = RelationshipFrom('SEAT', 'INCLUDED_IN', max_rels=4)
    # this sedan can have up to 4 seats
class Person(StructuredNode):
    car = RelationshipFrom('CAR', 'OWNED_BY', max_rels=1)
    # this car can only have up to 1 owner
class Router(StructuredNode):
    devices = RelationshipFrom('ROUTER', 'CONNECTED_TO', max_rels=30)

I am aware that I could do this easily enough in application logic with simple if statements, but it would be nice not to have to write them. I keep winding up with these duplicate relationships when things slip through in testing.

I suppose I'm just scared to dive into the world of open source contribs =\

@aanastasiou
Copy link
Collaborator

Not exactly helping but this is a Multiplicity constraint and the foundation for doing this is already there in StructuredRel via Cardinality. It is a matter of adding the constrain checks.

@ghost ghost closed this as completed Oct 8, 2018
This issue was closed.
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