I have an issue with the lookup field using in my charts. I need to pull one collection (customer) to another collection(program). CustomerId(object type in customer) is not the same in Program(it is string type in Program collection). I cannot change the types in the collection.
I followed some of the previous posts and did some changes in my aggregation pipeline(managed charts view in program collection).
{
$lookup: {
from: “customer”,
let: {customerId: “$customerId”},
pipeline:[
{$match: {
$expr:{
$and[
{$eq:[“$_id”:{$toObjectId: “$customerId”}]}
]
}
}
}],
as: “cid”
}
}
Not sure where I am doing it wrong. Page is not even letting me test my pipeline or save it. Is there anything wrong in my code?
Thanks in advance.