假设我有以下代码:
但是假设稍后我打电话过来:
link = neo4j.Path(this_node,"friends",friend_node) #create a link between 2 nodes
link.create(graph_db) #add the link aka the 'path' to the database
但是假设稍后我打电话过来:
link2 = neo4j.Path(friend_node,"friends",this_node)
link2.create_or_fail(graph_db)
基本上,link.create_or_fail()
是一种函数,它要么将 link2 路径添加到数据库中,要么如果路径已经存在则失败。
在这种情况下,当我调用 link = neo4j.Path(this_node,"friends",friend_node)
时,我已经在 this_node
和 friend_node
之间创建了一条路径,所以 link2.create_or_fail(graph_db)
不应该做任何事情。这样的功能是否可能?