apoc.refactor.rename.typeProperty

Procedure

apoc.refactor.rename.typeProperty(oldName STRING, newName STRING, rels LIST<RELATIONSHIP>, config MAP<STRING, ANY>) - renames the given property from oldName to newName for all RELATIONSHIP values. If a LIST<RELATIONSHIP> is provided, the renaming is applied to the RELATIONSHIP values within this LIST<RELATIONSHIP> only.

Signature

apoc.refactor.rename.typeProperty(oldName :: STRING, newName :: STRING, rels = [] :: LIST<RELATIONSHIP>, config = {} :: MAP) :: (batches :: INTEGER, total :: INTEGER, timeTaken :: INTEGER, committedOperations :: INTEGER, failedOperations :: INTEGER, failedBatches :: INTEGER, retries :: INTEGER, errorMessages :: MAP, batch :: MAP, operations :: MAP, constraints :: LIST<STRING>, indexes :: LIST<STRING>)

Input parameters

Name Type Default

oldName

STRING

null

newName

STRING

null

rels

LIST<RELATIONSHIP>

[]

config

MAP

{}

Output parameters

Name Type

batches

INTEGER

total

INTEGER

timeTaken

INTEGER

committedOperations

INTEGER

failedOperations

INTEGER

failedBatches

INTEGER

retries

INTEGER

errorMessages

MAP

batch

MAP

operations

MAP

constraints

LIST<STRING>

indexes

LIST<STRING>

Usage Examples

The examples in this section are based on the following sample graph:

CREATE (mark:Engineer {name: "Mark", city: "London"})
CREATE (jennifer:Engineer {name: "Jennifer", city: "St Louis"})
CREATE (michael:Engineer {name: "Michael", city: "Dresden"})
CREATE (jim:Engineer {name: "Jim", city: "London"})
CREATE (alistair:Engineer {name: "Alistair", city: "London"})

MERGE (jim)-[:COLLEAGUES {since: date("2006-05-01")}]->(alistair)
MERGE (mark)-[:COLLEAGUES {since: date("2018-02-01")}]->(jennifer)
MERGE (mark)-[:COLLEAGUES {since: date("2013-05-01")}]->(michael);

The following query changes the relationship property since to from for all relationships:

MATCH ()-[rel]->()
WITH collect(rel) AS rels
CALL apoc.refactor.rename.typeProperty("since", "from", rels)
YIELD batches, total, timeTaken, committedOperations
RETURN batches, total, timeTaken, committedOperations;
Table 1. Results
batches total timeTaken committedOperations

1

3

0

3

The following query returns all the paths in our graph after this refactoring has been done:

MATCH path = ()-[]->()
RETURN path
Table 2. Results
path

[{"name":"Mark","location":"London"},{"from":"2018-02-01"},{"name":"Jennifer","location":"St Louis"}]

[{"name":"Mark","location":"London"},{"from":"2013-05-01"},{"name":"Michael","location":"Dresden"}]

[{"name":"Jim","city":"London"},{"from":"2006-05-01"},{"name":"Alistair","city":"London"}]