pythonneo4jneomodel

Using multiple labels with Neomodel


I would like to know if there's a way to associate different labels to a class with NeoModel. If not, what module can allow me to do this?

My understanding is that when using the following class declaration, "Person" is a label.

class Person(StructuredNode):
    name = StringProperty(unique_index=True)
    age = IntegerProperty(index=True, default=0)

Let's say that I'd like to add a second label, "Employed", "Unemployed", "Student".

With Cypher I could use: CREATE(p:Person:Student)

Is there anyway I can achieve the same with NeoModel?

Notes: From my research working with labels yields faster queries than with properties (neo4j/cypher), which is why I would like employed/unemployed/student to be labels. Otherwise I would be fine adding "occupation" as a node property.


Solution

  • There isn't currently a method for adding labels to a neomodel structurednode, however this can be done via cypher. I'd be happy to add a method to do this also. You have to be-careful that the label doesn't conflict with a class name. You can return the labels of a node through its labels() method