How to filter 2 lists of items for uniques based on key/value?

I’m getting a list from RSS and another list from Mongo. I need to filter all items that don’t exist in Mongo and then process them. What would be the solution to this?

Workflow Goal:

  1. Read RSS feed
  2. Filter by keywords
  3. Check if article link already exist in the database
  4. If (not found)
  5. Insert to db
  6. Send to a webhook

What I’ve Tried:

I attempted to pass input data from Node 2 to Node 4 at the same time as Node 3 to Node 4 to check against but I can’t seem to extract key/values and merge them into a single array variable. This causes items from List A to be checked against one criteria only from List B resulting in false positives

Is it possible to use a Function node to compare 2 items lists?

Or have Mongo/Postgres continue if nothing is found? With number of rows/items found for Context would be helpful too

Sadly there was no simple way to do that. Even though there obviously should be. For that reason did I extend the Merge-Node and added the modes “Keep Key Matches” and “Remove Key Matches”.

Just released [email protected] which contains the additions. Now it is simply possible like that (you can simply copy&paste the JSON bellow into n8n):

1 Like

Perfect! :tada: My workflow is operating as intended. I’ll be having a lot of fun with this :blush:

Here is the link to my published workflow https://n8n.io/workflows/159

2 Likes

Just a heads up, some modes were mislabeled for the Merge node during a recent update. Keep Key Matches and Remove Key Matches are reversed

@dave0 I just checked if anything got mislabeled. Was however not the case. So I did check the functionality and also that worked fine. Here an example workflow:

If in “Keep Key Matches” it outputs 2 items. As only two dates match. If in “Remove Key Matches” it outputs 7 (there were 9 originally, 2 did match so 7 were left). So it seems to work perfectly.

So the only thing I can imagine right now is that you may be misunderstanding how the node works. It is not important if the values in “Property Input 1&2” match, what matters is if the values which get found for that keys match.

1 Like

I double checked my workflow, you are correct. I was using an expression instead of key name

The confusion arose due to having 2 installations of n8n though it still worked using the Merge node in an unintended way which is interesting to say the least

Sorry for the trouble. Thanks for looking into this for me

Ah great to hear that it works now.

Nothing to be sorry for. It is partly my fault as I did not find the time yet to create documentation for the Merge-Node. I really hope I get to that soon. Sorry!

1 Like