I want to add some nodes, but using match, if a node exists, just update it's counter.
In normal cypher I can use the ON MATCH
and ON CREATE
as part of the MERGE
command. How can I do something similar with the py2neo driver?
eg like
node_query = f"""
MERGE (nid:page{{name: "{page}" }})
ON CREATE
SET
nid.name = "{page}",
nid.count = 1,
nid.flow = "{row['flow']}"
ON MATCH
SET
nid.count = nid.count + 1
RETURN nid.count
"""
as far as I can see py2neo has a match
and merge
as separate commands and can't be triggered during the merge/insert as above. I would have to go back over the whole graph and set
individual values.