Reputation: 129
So I have a system whereby I will be handed in cypher queries to do specific operations (e.g. create a new node) as part of a pipeline.
The question I have, is that I would like to add additional properties and labels to this query that has been handed in to a process before it sends it off to the database (Neo4j) , but I would like to avoid a complex string parsing/update exercise.
For example, I may be given something like this:
CREATE (:testnode {tag_str: \"CgESpOVg\"})
But I want to add additional system (i.e. source process outside of the databse) provided properties and labels to this node creation before we hand it off to Neo4J.
Is there a way to do this without having to modify the original query, but instead just "bolting" on to it at the end?
As an obviously nonworking example, something like as follows?
CREATE (newnode:testnode {tag_str: \"mytag\"}) + <additional property foobar: usefuldata on variable new node>
The WITH clause sounds promising, but thus far I have not been able to make it work.
Upvotes: 0
Views: 144
Reputation: 1391
If you are allowing a string to be appended to the original query string before submitting, and there is a variable declared in the node, you can use the SET
clause:
CREATE (newnode:testnode {tag_str: \"mytag\"})
SET newnode.property1 = value1,
newnode.property2 = value2 ...
Upvotes: 1
Reputation: 66989
You can create APOC triggers to perform additional processing whenever a node or relationship is created or updated.
Upvotes: 0