I am trying to collect from a collection all contacts except those whose phone number is blacklisted. I have the following pipeline but I don't know how to reformat it so that instead of the hard-coded phone number, the mobile_phone field that is in the "contacts" collection is used.
db.getCollection("contactos").aggregate([
{
"$lookup": {
"from": "blacklist",
"localField": "mobile_phone",
"foreignField": "phone",
"as": "Blacklist"
}
},
{
"$match": {
"Blacklist.phone": {
"$ne": "+34000000000"
}
}
}
])