I am new to mongoDB and trying to make a query to find out unique ids in a collection based on other collection.
Collection1:
[{
id: 123,
name: xyz
},
{
id: 234,
name: abc
},
{
id: 345,
name: pqr
}]
Collection2 :
[{
id: 123,
status: y
},
{
id: 789,
status: n
},
{
id: 345,
status: y
}]
The result I am looking for is to get the unique elements in Collection1 based on ids from Collection2. Here in the above example below is the desired result as the id 234 is present in Collection1 but not in Collection2.
{
id: 234,
name: abc
}
Also I want to know the count of records matching. Any leads will be helpful.