I would like to create a node based on argument passed in func. In this createRelation func, one node is known "User" but other node might or might not exist. Depending on kind of relationship I want to create, I check if node of that type exist, if not create and then create a relationship. For e.g new node could be a book or a car .
def createRelationship(self, nodeName, value):
query = """
MATCH (u:User {username: {you}})
MERGE (b:nodeName {name: {value}})
ON CREATE SET b.name = {value}
CREATE UNIQUE (u) - [:OWNS] -> (b)
"""
return graph.cypher.execute(query, you=self.username, nodeName=nodeName, value=value)
I know node property can be used as the one passed in argument by declaring within {} but the same doesn't work for node