apoc.create.node
Syntax |
|
||
Description |
Creates a |
||
Input arguments |
Name |
Type |
Description |
|
|
The labels to assign to the new node. |
|
|
|
The properties to assign to the new node. |
|
Return arguments |
Name |
Type |
Description |
|
|
The created node. |
Usage Examples
This procedure provides a more flexible way of creating nodes than Cypher’s CREATE
clause.
The example below shows equivalent ways of creating a node with the Person
and Actor
labels, with a name
property of "Tom Hanks":
CALL apoc.create.node(["Person", "Actor"], {name: "Tom Hanks"});
CREATE (node:Person:Actor {name: "Tom Hanks"})
RETURN node;
node |
---|
(:Person:Actor {name: "Tom Hanks"}) |
But this procedure is mostly useful for creating nodes that have dynamic labels or properties. For example, we might want to create a node with labels or properties passed in as parameters.
The following creates labels
and properties
parameters:
:param labels => (["Human", "MovieStar"]);
:param properties => ({name: "Tom Cruise", placeOfBirth: "Syracuse, New York, United States"});
The following creates a node with labels and properties based on the previously defined parameters:
CALL apoc.create.node($labels, $properties);
node |
---|
(:Human:MovieStar {name: "Tom Cruise", placeOfBirth: "Syracuse, New York, United States"}) |