Skip to content
Advertisement

Compare 2 arrays containing rows of data and displays the matched records

I am trying to figure out a way that I could match the ‘userid’ on both arrays. Then the ones that match, keep the rows in MongoDBResults.

JavaScript

Desired output:

JavaScript

I tried:

JavaScript

also

JavaScript

Advertisement

Answer

You can index on userid and then compute the intersection of the keys:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement