i want to join employees collections and salaries collections based on some conditions
Employee.aggregate([
{
$match: {
nameAR: "عاصم ماجد شوشاري",
},
},
{
$lookup: {
from: "salaries",
let: { month: "$month", year: "$year" },
localField: "_id",
foreignField: "employeeId",
pipeline: [
{
$match: {
$expr: {
$eq: ["$month", "4"],
$eq: ["$year", "2022"],
},
},
},
],
as: "report",
},
},
]).exec(function (err, students) {
res.status(200).json(students);
});
the conditions are month equal to 4 and year equal to 2022, but what happens is it will return document when month is equal to 4 or year equal to 2022 so when any of the conditions specified is true, but i want only when both of them are true, how to solve it ?