requirement description:
mongodb contains the main information of two collection,theme storage topics, as well as an array of product id. Now if you want to find out the details of the products in products through the detailed id of the product, how should you query it? Or do you have a better design idea?
theme (theme)
{
"thmemId":"001",
"title":"theme1",
"productsId":[1,2,5]
}
products (product)
{
"id":"1",
"title":"",
"price":25
},
{
"id":"2",
"title":"",
"price":12
},
{
"id":"5",
"title":"",
"price":4000
}
the final effect you want to achieve is as follows:
{
"thmemId":"001",
"title":"theme1",
"productsId":[
{
"id":"1",
"title":""
"price":25
},
{
"id":"2",
"title":""
"price":12
},
{
"id":"5",
"title":""
"price":4000
}
]
}