I am trying to save a node with a label but i can't. Only node with properties will save on neo4j db. I appreciate if anyone can help with how to create a label on an object before i save it. I am using python and django with py2neo object-graph mapping for neo4j db. Here is the code. (In cypher this could be achieved using CREATE (n:Person{ id : id#, displayName : 'My Name' })
but i want to use py2neo object-graph mapping.)
In model.py
I have
class Person(object):
def __init__(self, id=None, displayName=None):
self.id = id
self.displayName = displayName
def __str__(self):
return self.displayName
in another .py
file i have
from py2neo import neo4j
from py2neo import ogm
graph_db = neo4j.GraphDatabaseService("http://localhost:7474/db/data/")`
def addPeople():
store = ogm.Store(graph_db)
worker = model.Person(1, "My Name")
store.save_unique("People","ID",worker.id,worker)`
Here the node will be created with id
and dispalyName
property, but not with label.