Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does the error "stage value is invalid" mean in MongoDB and how do I fix it?

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"
        }
    }
])
like image 599
Daibata Roy Avatar asked Oct 15 '25 11:10

Daibata Roy


1 Answers

Do not forget to use the "" on the values like this

{
  from: "user",
  localField: "userId",
  foreignField: "_id",
  as: "userInfo"
}
like image 185
giovanni cabral Avatar answered Oct 17 '25 03:10

giovanni cabral