we are trying to match _id object to mId foreignfield which is not working. looking for mondodb docs. they do not have anything on this. Is it possible with mongodb query or not?
_id as object in document
"_id" : ObjectId("56ab6663d69d2d1100c074db"),
mId as String in document
"mId" : "56ab6663d69d2d1100c074db",
query as below:
collection.aggregate([
{
$lookup:
{
from: "category",
localField: "_id",
foreignField: "mId",
as: "categories"
}
}
])
UDPATE
as a summary, mongodb does not support type coercion in $lookup. so to need above working i have to have _id and mId as ObjectId type in documents itself to make it work.