apoc.create.node

Details

Syntax

apoc.create.node(labels, props) :: (node)

Description

Creates a NODE with the given dynamic labels.

Input arguments

Name

Type

Description

labels

LIST<STRING>

The labels to assign to the new node.

props

MAP

The properties to assign to the new node.

Return arguments

Name

Type

Description

node

NODE

The created node.

Creating a node with dynamic labels using Cypher

Labels can be referenced dynamically in Cypher without using APOC.

Cypher syntax for creating a label dynamically
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 a node by passing in its 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"});
apoc.create.node
CALL apoc.create.node($labels, $properties);
CREATE clause
CREATE (node:$($labels) $properties)
RETURN node;
Results
node

(:Human:MovieStar {name: "Tom Cruise", placeOfBirth: "Syracuse, New York, United States"})