Reputation: 119
I've been trying to figure out how to use a Python client to insert nodes into my graph database. I need to add nodes that might already exist or might not exist yet, along with their labels and properties.
I've gone through the Memgraph documentation, but I couldn't find a clear answer on how to do this.
Here's what I'm trying to achieve:
Upvotes: 1
Views: 58
Reputation: 120
MERGE
with ON CREATE SET
and ON MATCH SET
should do the trick. It allows you to update object differently depending on whether they exist or not. If that object doesn't exist, then it triggers ON CREATE (because it needs to be created). On the other hand, if the object already exists, then it's being matched so it triggers ON MATCH SET.
Upvotes: 1