apoc.create.nodes
Syntax |
|
||
Description |
Creates |
||
Input arguments |
Name |
Type |
Description |
|
|
The labels to assign to the new nodes. |
|
|
|
The properties to assign to the new nodes. |
|
Return arguments |
Name |
Type |
Description |
|
|
The created node. |
Creating nodes with dynamic labels using Cypher
Labels can be referenced dynamically in Cypher without using APOC.
CREATE (n:$(label))
The dynamically calculated label must evaluate to a STRING
or LIST<STRING>
.
For more information, see the Cypher Manual → CREATE nodes and relationships using dynamic node labels and relationship types.
Usage Examples
The example below demonstrates how to use Cypher and APOC to create nodes by passing in their labels and properties dynamically using a map:
The following creates labels
and properties
parameters:
:param labels => (["Human", "MovieStar"]);
:param properties => ([{name: "Tom Cruise", placeOfBirth: "Syracuse, New York, United States"}, {name: "Reese Witherspoon", placeOfBirth: "New Orleans, Louisiana, United States"}]);
CALL apoc.create.nodes($labels, $properties);
UNWIND $properties AS propertyMap
CREATE (node:$($labels) propertyMap)
RETURN node;
node |
---|
(:Human:MovieStar {name: "Tom Cruise", placeOfBirth: "Syracuse, New York, United States"}) |
(:Human:MovieStar {name: "Reese Witherspoon", placeOfBirth: "New Orleans, Louisiana, United States"}) |