Hi, I run this aggregate in the mongo-compass and it returns the right value for me but I could not use it in the MongoDB chart:
aggregate:
[
{
$lookup: {
from: 'leads',
localField: 'lead',
foreignField: '_id',
as: 'lookuped_lead'
}
},
{
$unwind: {
path: '$lookuped_lead',
preserveNullAndEmptyArrays: true
}
},
{
$match: {
'lookuped_lead.followUpBy': {
$type: 'objectId'
}
}
},
{
$lookup: {
from: 'admins',
localField: 'lookuped_lead.followUpBy',
foreignField: '_id',
as: 'lookuped_followUpBy'
}
},
{
$unwind: {
path: '$lookuped_followUpBy',
preserveNullAndEmptyArrays: true
}
},
{
$addFields: {
followUpBy_info: '$lookuped_followUpBy'
}
}
]
NOTE: I copy and paste this aggregate in the query in MongoDB chart