Error connecting multiple nodes into one

Why doesn’t a workflow like this work in practice?

I’m trying to run 3 nodes and send them to a single node to handle them all at once via code, but this doesn’t work in practice. I don’t know if I’m doing something wrong (since I had the impression that I had managed to do this successfully before) or if there really is no way…

Can someone explain it to me?

PS.: I can’t share the workflow, but here’s a picture of what I’m trying to do:

This works with success…

  • n8n version: 1.67.1
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker
  • Operating system: Ubuntu 22

Hey @agldiasdigital ,
Can you please share the workflow.

I need to have a look at the code node specifically. (Want to understand how you are taking input from the previous node into the code node.)

Hey! Is something like this:

So basically you are using the code node to merge all the data from the previous node right?

if that’s TRUE, try using Merge node instead of the code node.

{FDBF6C85-0EDA-4FE1-AF2C-804154077CDB}

Now that I remember, it was with Merge that I managed to execute using the data from the 3 nodes at once :sweat_smile:

The problem is: how will I correctly structure the data in the way I need, using Merge?

The output structure I need is:
node1: string “total” as “recordsTotal”
node2: string “filtered” as “recordsFiltered”
node3: array “json” as “data”

I didn’t find a way to do this with it. Unless I’m looking in the wrong place. Can you help me with this?

Add an aggregate node after each Postgres node and set a different output field for them. Next - use the merge node in Combine mode, combine by position type. If all your queries output only one item, then you don’t need the aggregate node, instead use the edit field node to rename fields

But I prefer using the design, like in your second screenshot from the first post.

Wow, a lot of work for something simple haha. The way you mentioned, it’s better to do the second option from the initial post, it has a lot fewer steps and avoids unnecessary nodes and executions.

There is no way to have the data structured in the way I need in the output just by using the Merge node, right?

Hey @agldiasdigital ,

I would love to help you out…

Can you please share the sample outputs you get from all the 3 different sources.

You can. Depending on how many items your postgres nodes will return, the setup will be different.

Here is an example of both options (when there is one output item and more than 1)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.