Mongoose data query problem?

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
        }
    ]
}

idea: I think a product data is a data that doesn't change frequently or even does not exist, so I think we can send the product data directly to the theme, such as

.
{
    'thmemId':'001',
    'title':'theme1',
    'products':[
        {
            'id':'1',
            'title':'',
            'price':25
        },
        {
            'id':'2',
            'title':'',
            'price':12
        },
        {
            'id':'5',
            'title':'',
            'price':4000
        }
    ]
}

if you want to change the data of a certain product. All you have to do is change what is in the product table, and then go to theme to find out if there is this product and change it together.
if you can't change the data structure, or if you think there will be other problems with changing the data structure. Then query it. Use Aggregation Pipeline, first $unwind, then $lookup, and then $group. I'll show you api,.
Aggregation Pipeline


populate


,.

var theme = {
    'thmemId':'001',
    'title':'theme1',
    'productsId':[1,2,5]
}
products.find({id: {$in:theme.productsId}}).then(rs=>{
    theme.productsId = rs;
})
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b32d1a-2be71.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b32d1a-2be71.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?