MongoDB $lookup 与 Mongoose 填充
MongoDB $lookup vs Mongoose populate
我看过this和其他类似标题的问题,none回答我的问题。
我正在浏览 mongoose documentation 我阅读的地方
MongoDB has the join-like $lookup aggregation operator in versions >=
3.2. Mongoose has a more powerful alternative called populate(), which lets you reference documents in other collections.
populate()
在 mongoose 中如何工作使其比 MongoDB 的 $lookup
更强大?
mongoose 不是一个帮助 nodejs 用户使用 mongodb 的工具吗?如果是这样的话,mongoose 怎么会有 MongoDB 没有的功能呢?喜欢 populate()
?
猫鼬的populate()
方法是否在幕后使用MongoDB的$lookup
?
感谢问题评论中的github thread shared by Grégory NEUT,我已经能够确定某些事实:
- Mongoose 的 populate() 方法不在幕后使用 MongoDB 的 $lookup。它只是对数据库进行另一个查询。
- Mongoose 没有 MongoDB 没有的功能。
populate()
只进行两次或更多次查询。
How does populate() in mongoose work that makes it more powerful than
MongoDB's $lookup?
在我看来,有的地方可以用populate()
,有的地方可以用$lookup
。对于更复杂的查询,聚合管道中的 $lookup
效果最好。
我看过this和其他类似标题的问题,none回答我的问题。
我正在浏览 mongoose documentation 我阅读的地方
MongoDB has the join-like $lookup aggregation operator in versions >= 3.2. Mongoose has a more powerful alternative called populate(), which lets you reference documents in other collections.
populate()
在 mongoose 中如何工作使其比 MongoDB 的 $lookup
更强大?
mongoose 不是一个帮助 nodejs 用户使用 mongodb 的工具吗?如果是这样的话,mongoose 怎么会有 MongoDB 没有的功能呢?喜欢 populate()
?
猫鼬的populate()
方法是否在幕后使用MongoDB的$lookup
?
感谢问题评论中的github thread shared by Grégory NEUT,我已经能够确定某些事实:
- Mongoose 的 populate() 方法不在幕后使用 MongoDB 的 $lookup。它只是对数据库进行另一个查询。
- Mongoose 没有 MongoDB 没有的功能。
populate()
只进行两次或更多次查询。
How does populate() in mongoose work that makes it more powerful than MongoDB's $lookup?
在我看来,有的地方可以用populate()
,有的地方可以用$lookup
。对于更复杂的查询,聚合管道中的 $lookup
效果最好。