Since 2014, there was an issue that relationship to multiple object types is not available: https://github.com/robinedwards/neomodel/issues/126
It's now 2016, and still I'm not aware of any solution regarding this critical issue.
Example for usage:
class AnimalNode(StructuredNode):
tail_size = IntegerProperty()
age = IntegerProperty()
name = StringProperty()
class DogNode(AnimalNode):
smell_level = IntegerProperty()
class CatNode(AnimalNode):
vision_level = IntegerProperty()
class Owner(StructuredNode):
animals_owned = RelationshipTo("AnimalNode", "OWNED_ANIMAL")
dog_node1 = DogNode(name="Doggy", tail_size=3, age=2, smell_level=8).save()
cat_node1 = CatNode(name="Catty", tail_size=3, age=2, vision_level=8).save()
owner = Owner().save()
owner.animals_owned.connect(dog_node1)
owner.animals_owned.connect(cat_node1)
If I try to access animals_owned
relationship of the owner
, as you expect, it retrives only AnimalNode baseclasses and not its subclasses (DogNode
or CatNode
) so I am not able to access the attributes: smell_level
or vision_level
I would want something like this to be permitted in neomodel:
class Owner(StructuredNode):
animals_owned = RelationshipTo(["DogNode", "CatNode"], "OWNED_ANIMAL")
and then when I will access animals_owned
relationship of owner
, It will retrieve objects of types DogNode
and CatNode
so I can access the subclasses attributes as I wish.
But the connect method yields the following error:
TypeError: isinstance() arg 2 must be a type or tuple of types
Is there any way to achieve that in neomodel in an elegant way?
Thanks!