如何从一个集合中复制文档的主要键,并将其保存在类似数据库中的另一个集合中
我想使用$查找加入数据库中的两个集合。我需要从一个集合中获取主键(“ _ ID”),并将它们添加到另一个集合中,为“ ID2”,以便使用查找。如何执行此操作?
我想复制的主要钥匙的第一个集合
第二个集合,我希望第一个集合的主要键复制为“ _id2”
“收集到第二个集合,并将其保存为“ _id2”。他们执行$查找,并将两个收藏夹与我的外国菲尔德(我的外国人)在一起。
I want to use $lookup to join two collections in my database. I need to take primary keys("_id") from one collection and add them to another collection as “id2” in order to use lookup. How can I perform this operation?
First Collection whose primary key I want to copy
Second collection where I want the First collection's primary key copied as "_id2"
I want to copy the “_id” for first collection to the second collection and save it as “_id2”. And them perform $lookup and get both the collections together with my foreignField being “_id2”.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论