I am new in nosql and I need a query that works like join. I hope you can help me with that. User collection which has id name Idea collection which includes id comment user_id
one can have many comments and I would like to reach the comments given by user Idea.comment User.name is the result I want I hope you can help me thx
db.ProjectIdea.aggregate([
{
$lookup:{
from:"User",
localField:"createdUser",
foreignField:"_id",
as:"kim"
}
}
]).forEach(
function(u){
print(u.kim[0].name;
}
);
however, some users do not have name attribute defined so i am havin error How do I perform the SQL Join equivalent in MongoDB? i tried the thing in the link before but could not solve the whole problem