gpt4 book ai didi

node.js - 如何使用 Node js映射mongodb中的两个集合

转载 作者:可可西里 更新时间:2023-11-01 10:08:23 25 4
gpt4 key购买 nike

<分区>

我对如何使用 mongoclient 在 mongodb 中映射两个集合有疑问。我试过了,但它不起作用。如何解决它

group_promotion合集

{ 
"_id" : ObjectId("5cf7679a0b0bed2e7483b998"),
"group_name" : "Latest",
"products" : [ObjectId("5cecc161e8c1e73478956333"),ObjectId("5cecc161e8c1e73478956334")]
}

产品合集

{ 
"_id" : ObjectId("5cecc161e8c1e73478956333"),
"product_name" : "bourbon"
},
{
"_id" : ObjectId("5cecc161e8c1e73478956334"),
"product_name" : "bour"
}

预期输出:

{   
"_id" : ObjectId("5cf7679a0b0bed2e7483b998"),
"group_name" : "Latest",
"products" : [{
"_id" : ObjectId("5cecc161e8c1e73478956333"),
"product_name" : "bourbon"
},{
"_id" : ObjectId("5cecc161e8c1e73478956334"),
"product_name" : "bour"
}]
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com