apoc.create.setProperties

Procedure

apoc.create.setProperties(nodes ANY, keys LIST<STRING>, values LIST<ANY>) - sets the given properties to the given NODE values.

Signature

apoc.create.setProperties(nodes :: ANY, keys :: LIST<STRING>, values :: LIST<ANY>) :: (node :: NODE)

Input parameters

Name Type Default Description

nodes

ANY

null

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

keys

LIST<STRING>

null

The property keys to add to the given NODE values.

values

LIST<ANY>

null

The values to add to the properties.

Output parameters

Name Type

node

NODE

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 node properties on Person nodes, by running the following query:

MATCH (p:Person)
WITH p, keys(p) AS keys
CALL apoc.create.setProperties(p,[k in keys | k + "Copy"], [k in keys | p[k]])
YIELD node
RETURN node;
Table 1. Results
node

{"name":"Jennifer","partition":4,"community":1,"nameCopy":"Jennifer","partitionCopy":4,"communityCopy":1}

{"name":"Karin","partition":2,"community":4,"nameCopy":"Karin","partitionCopy":2,"communityCopy":4}

{"name":"Mark","partition":3,"community":3,"nameCopy":"Mark","partitionCopy":3,"communityCopy":3}