MongoDB $lookup vs Mongoose populate
Thanks to a github thread shared by Grégory NEUT in the question's comments I have been able to establish certain facts:
- Mongoose's populate() method does not use MongoDB's $lookup behind the scenes. It simply makes another query to the database.
- Mongoose does not have functionalities that MongoDB does not have.
populate()
just makes two or more queries.
How does populate() in mongoose work that makes it more powerful thanMongoDB's $lookup?
In my opinion, there are places to use populate()
and others to use $lookup
. For more complex queries $lookup
in an aggregation pipeline would work best.