HI!
When I fetch data from Postgres I get in response:
[
{
"id": "67c64fb6-c8a3-4d0b-bfcc-07731ea9878f"
},
{
"id": "01794f93-06f0-45e2-9f48-4cbe68c6bf37"
}
]
How do I put this together in one line? For the query:
INSERT INTO table (id, name) VALUES (...) , (...)
ON CONFLICT
DO NOTTING;
jan
2
You can do that in a Function-Node. Not sure where you get the name from, so did now simply hardcode it to a static value.
Here the code:
return [
{
json: {
query: 'INSERT INTO table (id, name) VALUES ' + items.map(item => `("${item.json.id}", "the name")`).join(', ') + ' ON CONFLICT DO NOTHING;'
}
}
];
And here an example workflow:
When I added this to my workflow I got:
ReferenceError: items is not defined
jan
4
That is not possible. Please copy the workflow JSON I posted above and past it into yours. It has to work.