apoc.create.setRelProperties

Procedure

apoc.create.setRelProperties(rels ANY, keys LIST<STRING>, values LIST<ANY>) - sets the given properties on the RELATIONSHIP values.

Signature

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

Input parameters

Name Type Default Description

rels

ANY

null

rels can be of type STRING (elementId()), INTEGER (id()), RELATIONSHIP or LIST<STRING | INTEGER | RELATIONSHIP>.

keys

LIST<STRING>

null

The property keys to add to the given RELATIONSHIP values.

values

LIST<ANY>

null

The values to add to the properties.

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"