apoc.trigger.propertiesByKey

This is the APOC Extended documentation.

APOC Extended is not supported by Neo4j. For the officially supported APOC Core, go to the APOC Core page.

Function Apoc Extended

Signature

apoc.trigger.propertiesByKey(propertyEntries :: MAP?, key :: STRING?) :: (LIST? OF ANY?)

Input parameters

Name Type Default

propertyEntries

MAP?

null

key

STRING?

null

Usage Examples

This function is used inside an apoc.trigger.add.adoc Cypher statement.

We can use it to conditionally run Cypher statements when properties are added or removed. For example, we can connect nodes with a genre property to a Genre node, with the following trigger:

CALL apoc.trigger.add(
  'triggerTest',
  'UNWIND apoc.trigger.propertiesByKey($assignedNodeProperties, "genre") as prop
   WITH prop.node as n
   MERGE (g:Genre {name: n.genre})
   MERGE (n)-[:HAS_GENRE]->(g)
   ',
  {}
);

Let’s now create a Movie node with a genre property:

CREATE (:Movie {title: "The White Tiger", genre: "Crime"});

And now let’s find all HAS_GENRE relationships:

MATCH path = ()-[:HAS_GENRE]->()
RETURN path;
Table 1. Results
path

(:Movie {genre: "Crime", title: "The White Tiger"})-[:HAS_GENRE]→(:Genre {name: "Crime"})