Create New Nodes from Array

Greetings,

Using node.js and Express

I have an input field name="tablenames" and I can pass this to my server using const {tablenames} = req.body and I can console.log and see an array of the expected table names...

console.log(tablenames);

[table1, table2, table3, table4, table5]

I am trying to take the tablenames array and build 5 new nodes each with the .Title of a given table seen in the array.

I've tried the following queries, but am at a loss as to how to do what I thought would be a fairly simple task.

Try 1

Merge (t:Table {Title: $tablenames})

The result of this is 1 new node created with all 5 of the table1~5 as the .Title

Try 2

UNWIND $tablenames AS map
CREATE (n:Table)
SET n = map.Title

I realize I'm not using map correctly as it return an error, but I'm trying to follow the Create documentation for creating multiple nodes.

How do I create these 5 separate nodes from the array and give them the titles listed in the array?

Many Thanks!

Perfect, thank you!
(migrated from khoros post Solved: Re: Create New Nodes from Array - Neo4j - 59720)

Try this:

UNWIND $tablenames AS table
CREATE (n:Table)
SET n.Title = table

Or this:

forEach(i in $tablenames |
CREATE (n:Table)
SET n.Title = i)