MongoDB Lookup Aggregation Link to heading
The following will query for documents from a collection matching a id as a foreign id to a second collection.
db.mycollection1.aggregate([
{
$lookup: {
from: "mycollection2",
localField: "_id",
foreignField: "_id",
as: "matched_docs",
}
},
{
$match: {
matched_docs: {$eq: []}
}
}
])