Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
08-30-2022 10:08 AM - edited 08-30-2022 10:32 AM
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!
Solved! Go to Solution.
08-30-2022 10:27 AM - edited 08-30-2022 10:29 AM
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)
08-30-2022 10:27 AM - edited 08-30-2022 10:29 AM
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)
08-30-2022 10:59 AM
Perfect, thank you!
All the sessions of the conference are now available online