Can I have a relationship to different kind of nodes?
I need something like
rel = RelationshipTo('NodeTypeOne|NodeTypeTwo', 'REL');
or
rel = RelationshipTo('StructuredNode', 'REL');
Try splitting the relationship into two relationship declarations, within the class you defined:
rel1 = RelationshipTo('NodetypeOne', 'REL')
rel2 = RelationshipTo('NodetypeTwo', 'REL')
A quick example:
class NodeType1(StructuredNode):
name = StringProperty()
class NodeType2(StructuredNode):
name = StringProperty()
class NodeType3( StructuredNode ):
name = StringProperty()
rel1 = RelationshipTo( 'NodeType1', 'REL')
rel2 = RelationshipTo( 'NodeType2', 'REL')
n1 = NodeType1(name='nodetype1').save()
n2 = NodeType2(name='nodetype2').save()
n3 = NodeType3(name='nodetype3').save()
n3.rel1.connect(n1)
n3.rel2.connect(n2)
We'll end up with n3
having connections to n1
and n2
with the same relationship name REL
. Here's the end result: