+ 10
Mongodb
As you all know that in mongodb we can only perform left outer join using $lookup. My question is that why we can't perform other joins like we do in sql ?
3 Answers
+ 1
The thing with NoSQL (MongoDB) is designed for flexible schemas and very fast reading and writing.
To each input document the $lookup stage adds a new array field whose elements are the matching documents from the "joined" collection. The $lookup stage passes these reshaped documents to the next stage.
The operation will correspond to the following SQL STATEMENT
SELECT *, <output array field>
FROM collection
WHERE <output array field> IN (SELECT *
FROM <output array field>
WHERE <foreignField>=<collection.localField>);
I hope this might be helpful!
0
Hello, please mind your tags - your question does not relate to any of your tags except for mongodb.
Your only tag shall be "mongodb"