-2

I want to know how to make MongoDB query same for this mysql query

"SELECT * FROM `folders` `F` JOIN `files` `I` ON I._id IN F.filesId;"
Siraj Alam
  • 9,217
  • 9
  • 53
  • 65
  • 4
    Possible duplicate of [How do I perform the SQL Join equivalent in MongoDB?](https://stackoverflow.com/questions/2350495/how-do-i-perform-the-sql-join-equivalent-in-mongodb) – Raymond Nijland Jun 28 '19 at 15:27

1 Answers1

0
db.folders.aggregate([
{ 
    $lookup: { 
        from: "files",
        localField: "_id", 
        foreignField: "filesId", //_id is ObjectId() so  filesId fields on 
        as: "docs"               //  files table mustbe ObjectId Save
    } 
}
])

"https://docs.mongodb.com/manual/reference/operator/aggregation/lookup/"