Closed darixsamani closed 1 year ago
Hi @darixsamani,
I've just pushed a new version #11 which adds support for multiple labels by adding a __secondarylabels__
class variable where you can provide a list of additional labels to apply to a node.
You'll need v1.0.0 pip install --upgrade neontology
. The new version also upgrades to Pydantic v2 which may need require some changes to your models.
class ElephantNode(BaseNode):
__primaryproperty__: ClassVar[str] = "name"
__primarylabel__: ClassVar[Optional[str]] = "Elephant"
__secondarylabels__: ClassVar[Optional[list]] = ["Animal", "Mammal"]
name: str
Check out the docs here.
Neontology doesn't natively support advanced queries - Neo4j's Cypher language is great for that though. You can run queries using the Neo4j driver of the Neontology GraphConnection object. For example:
import neo4j
from neontology import init_neontology, GraphConnection
init_neontology()
gc = GraphConnection()
cypher_query = """
MATCH (p:Person)
RETURN COLLECT({name: p.name})
"""
result = gc.driver.execute_query(cypher_query, result_transformer_=neo4j.Result.single)
print(result)
# [{'name': 'Alice'}, {'name': 'Bob'}]
Again, I've updated the docs with some more info.
Hope that helps!
in Neo4j, A node can have a multilabel, how can we define several labels using your tools?
How I can launch an advanced query?