You could refer this sample playground
db.orders.aggregate([
{
"$lookup": {
from: "inventory",
let: {
id: "$_id",
item: "$item"
},
pipeline: [
{
"$match": {
$expr: {
"$eq": [
"$_id",
"$$id"
],
"$eq": [
"$sku",
"$$item"
]
}
}
}
],
as: "outputs"
}
}
])
Reference
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…