Reputation: 11
with {conatcts_count:10,account_count:20,time_stamp:'2010_12_231'} as data
merge (u:Customers1 {name:'sai',id:1})-[r:REL {conatcts_count:data.conatcts_count,account_count:data.account_count,ts:data.time_stamp}]-(s:Sale1 {name:'sales_123',id:1})
I have tried this... But it always creating a new nodes when I am changing the values of JSON. I am looking for something which takes the JSON timestamp and create a relation with same nodes.
Upvotes: 1
Views: 30
Reputation: 7478
It's due to the MERGE
command.
Usage : MERGE pattern
The merge command performs a MATCH pattern
at first, and if there is no result, then it does a CREATE pattern
So if you don't have any relationship between yours n
and s
nodes, the MATCH returns nothing, and so ask the DB to create the pattern (u)-[:REL]->(s)
.
What you should instead, it's this :
with {conatcts_count:10,account_count:20,time_stamp:'2010_12_231'} as data
MERGE (u:Customers1 {name:'sai',id:1})
MERGE (s:Sale1 {name:'sales_123',id:1})
MERGE (u)-[:REL {conatcts_count:data.conatcts_count,account_count:data.account_count,ts:data.time_stamp}]-(s)
Upvotes: 2