apoc.create.setRelPropertiesProcedureDeprecated in Cypher 25
| This procedure is deprecated.
To dynamically set properties, use Cypher’s  | 
| Syntax | 
 | ||
| Description | Sets the given properties on the  | ||
| Input arguments | Name | Type | Description | 
| 
 | 
 | The relationships to set properties on. | |
| 
 | 
 | The keys of the properties to set on the given relationships. | |
| 
 | 
 | The values of the properties to set on the given relationships. | |
| Return arguments | Name | Type | Description | 
| 
 | 
 | The updated relationship. | |
Set Properties using Cypher
Properties can be referenced dynamically in Cypher without using APOC.
SET n[key]The dynamically calculated key must evaluate to a STRING value.
For more information, see the Cypher Manual → Dynamically setting or updating a property.
Usage Examples
The examples in this section are based on the following sample graph:
CREATE (jennifer:Person {name: "Jennifer", community: 1, partition: 4})
CREATE (karin:Person {name: "Karin", community: 4, partition: 2})
CREATE (elaine:Person {name: "Elaine", community: 3, partition: 3})
MERGE (jennifer)-[:FRIENDS {since: datetime("2019-06-01")}]-(karin)
MERGE (jennifer)-[:FRIENDS {since: datetime("2019-05-04")}]-(elaine);We can duplicate all relationship properties using both APOC and Cypher:
MATCH (:Person)-[friends:FRIENDS]->(:Person)
WITH friends, keys(friends) AS keys
CALL apoc.create.setRelProperties(friends,[k in keys | k + "Copy"], [k in keys | friends[k]])
YIELD rel
RETURN startNode(rel).name AS start, rel, endNode(rel).name AS end;MATCH (p1:Person)-[friends:FRIENDS]->(p2:Person)
FOREACH (k IN keys(friends) | SET friends[k + "Copy"] = friends[k])
RETURN DISTINCT p1.name AS start, friends, p2.name AS end;| start | rel | end | 
|---|---|---|
| "Jennifer" | [:FRIENDS {sinceCopy: 2019-05-04T00:00Z, since: 2019-05-04T00:00Z}] | "Elaine" | 
| "Jennifer" | [:FRIENDS {sinceCopy: 2019-06-01T00:00Z, since: 2019-06-01T00:00Z}] | "Karin" |