I have two collections and both of them have the same key names platform, channel and month. When I am using lookup, the let step is taking the variables from the first collection and not the collection b. Using the dot operator also does not work.
Another problem is that month and year operators are not working in let.
How do I fix these?
{
$lookup: {
from: "b",
let: {
rev_platform: "$b.platform",
rev_channel: "$b.channel",
rev_month: {$month:'$b.month'},
rev_year: {$year:'$b.month'}
},
pipeline: [
{ $match:
{ $expr:
{ $and:
[
{ $eq: [ "$platform", "$$rev_platform" ] },
{ $eq: [ "$channel", "$$rev_channel" ] },
{ $eq: [ "$month", "$$rev_month" ] },
{ $eq: [ "$year", "$$rev_year" ] },
]
}
}
},
],
as: "fromB"
}
},