Hi,
I’m trying to create an aggregate pipeline query with a lookup to join 2 tables that takes as a localField a pointer and as a foreignField an object Is. However I can’t seem to be able to obtain a successful result. If I place string values as foreign and local fields everything works but I can’t figure out how to do the same with pointers and object ids.
Any suggestions?
I don’t have suggestions now. You could share some of the code that you have now.
Sure, here is the code I am currently testing:
const query = new Parse.Query("Sales");
const pipeline = [
{
lookup: {
from: "Product",
localField: "product",
foreignField: "objectId",
as: "soldProduct",
},
},
];
var res = await query.aggregate(pipeline, {useMasterKey: true});
console.log(res);
The “product” localField is my pointer, while the “objectId” foreignField is the objectId.
This code however does not seem to work.
try id here instead of objectId, or _id
I’ve already tried all combinations but none of them work.
maybe this gets you closer: