Is there an equivalent to LEFT JOIN query where right collection isn\'t exists in MongoDB?
SQL:
SELECT * FROM TableA as A LEFT JOIN TableB as B ON A
Neil Lunn's solution is working, but I have another approach, because $lookup pipe does not support Shard collection in the "from" statement.
So I used to use simple java script as follows. It's simple and easy to modify. But for performance you should have proper indexes!
var mycursor = db.collA.find( {}, {_id: 0, myId:1} )
mycursor.forEach( function (x){
var out = db.collB.count( { yourId : x.myId } )
if ( out > 0) {
print('The id exists! ' + x.myId); //debugging only
//put your other query in here....
}
} )