擅长:python、mysql、java
<p>回答我自己的问题,希望这对其他人也有帮助。在</p>
<pre><code> rel_list = list(graph.match(start_node=user, end_node=post, rel_type="UPVOTED")
if len(rel_list) > 0:
# delete the relationship from the graph
# fetch the ID of the relationship -> rel_id
query = '''
MATCH (a:NeoZotr)-[r:LIKED]->(b:NeoZot)
WHERE ID(r) = {x}
DELETE r
'''
graph.cypher.execute(query,x=rel_id)
else:
# create the relationship
rel = Relationship(user, "UPVOTED", post)
graph.create_unique(rel)
</code></pre>
<p>如果最后出现TypeError(就像在我的例子中一样),那么您获取的rel\uid可能是unicode样式。在这种情况下传递int(rel_id)。在</p>