apoc.create.setRelProperties

Procedure APOC Core

apoc.create.setRelProperties( [rel,id,ids,rels], [keys], [values]) - sets the given properties on the relationship(s)

Signature

apoc.create.setRelProperties(rels :: ANY?, keys :: LIST? OF STRING?, values :: LIST? OF ANY?) :: (rel :: RELATIONSHIP?)

Input parameters

Name Type Default

rels

ANY?

null

keys

LIST? OF STRING?

null

values

LIST? OF ANY?

null

Output parameters

Name Type

rel

RELATIONSHIP?

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, by running the following query:

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;
Table 1. Results
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"