Data Passing Through Postgres Node Dropped

Hey!

I have a workflow which is triggered by a webhook to listening to incoming requests. The request is then passed to a Postgres node which checks if a particular user exists based on a userId in the incoming request payload. Postgres will check if this userId is in the database and return 0 or 1.

The problem is that the Postgres node drops the original webhook data and only returns the result of the count. How can modify this behaviour and append the Postgres node’s result to the original data so nodes further down can act on both data items?

SELECT COUNT(1)
FROM user
WHERE UserId = {{$json[“body”][“data”]}};

[{
“count”: “0”
}]

Welcome to the community @sigmet.

You can use a Merge-Node for this with “Mode” set to “Merge By Index”. Then you connect the nodes of which you want to merge the data of. In your case that would be Input-1 the Postgres-Node and Input-2 the Webhook-Node.

Thanks!

I’m trying to understand the logic: Is it expected behaviour that some nodes drop the data while some append to the json object, like the function node?

Exactly. After all, are nodes performing totally different actions. If you have the Google Sheet-Node set to “Read” you expect it to read data and replace the incoming data, the same for the Posgres-Node. If you have the Set-Node you expect it to append/set the data (unless specifically set to do replace it).

The Function-Node does what you tell it to do. If you write code to replace the data it will replace it if you write code to append/set data it will do that.