I am trying to use lookup to join two collections in MongoDB compass, but I get this error and I have no clue how to fix it. I am totally new to MongoDb, please help!
{
from: power_plants,
localField: power_plant_id,
foreignField: plant_id,
as: result
}
enter image description here
i tired this code as well but it still doesnt work.
db.greenhouse.aggregate([
{ $lookup:
{
from: "power_plants",
localField: "power_plant_id",
foreignField: "plant_id",
as: "result"
}
}
])
Do not forget to use the "" on the values like this
{
from: "user",
localField: "userId",
foreignField: "_id",
as: "userInfo"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With