cancel
Showing results forΒ
Did you mean:Β

## Create New Relations based on Existing Relations for a Node

Node Clone

Warm Greetings to Neo4j Community!

We've following requirement which we are trying to address in Neo4j -

1. A Node is connected to another Node through many relationships, and each of these relationships capture a number of metrics based on a given date. For e.g

``````(A) -[:HAS {metric: 'a1', date: '2021-10-10', value: 40}]->(B)
(A) -[:HAS {metric: 'a2', date: '2021-10-10', value: 60}]->(B)
(A) -[:HAS {metric: 'a3', date: '2021-10-10', value: 70}]->(B)
(A) -[:HAS {metric: 'a4', date: '2021-10-10', value: 10}]->(B)
``````
``````2.  There is a need to Create New relationships between A and B, which will contain exactly the same information as existing relationships except the 'date' property, which is to be updated with a new date.

(A) -[:HAS {metric: 'a1', date: '2021-10-12', value: 40}]->(B)
(A) -[:HAS {metric: 'a2', date: '2021-10-12', value: 60}]->(B)
(A) -[:HAS {metric: 'a3', date: '2021-10-12', value: 70}]->(B)
(A) -[:HAS {metric: 'a4', date: '2021-10-12', value: 10}]->(B)

3.  Requirement is not to Update the existing relations. Only Create new relations with new 'date' but rest of the properties on the relations should be same.
``````

Considering that there exists 100+ such relationships between A and B for a given date, can we copy(utilize) the existing relations between A and B, and create new relations based on that copied info, with updated 'date' property.

Can you please advice is there an easy way to achieve the objective.

``````match(A) where id(A) = 1