RT,使用 mongoose,有如下两个数据,我想把产品参数据表,对应的产品查询出来,我目前只会查询一级的,在 Array 里面包裹的数据就不知道怎么取出来了,看了一天的官网文档也没看明白……惭愧惭愧,求大神给指个道吧。
示例数据如下:
// 产品数据表 product
{
"uid": "5f460572f639b62baa839baa",
"productCounts": 17,
"productItems": [{
"is_variants": false,
"totalVariants": 1,
"id": 12345 "tetle": "苹果"
},
{
"is_variants": false,
"totalVariants": 1,
"id": 23456 "tetle": "西瓜"
},
{
"is_variants": false,
"totalVariants": 1,
"id": 56789 "tetle": "荔枝"
},
...
]
}
// 产品参数数据表 options
{
"uid": "5f460572f639b62baa839baa",
"pid":23456,
"ditch": "weixin",
"postcode": 518000,
"is_pay": true
}
我想要的数据如下
{
"is_variants": false,
"totalVariants": 1,
"id": 12345,
"tetle": "苹果",
"options": {
"uid": "5f460572f639b62baa839baa",
"pid": 23456,
"ditch": "weixin",
"postcode": 518000,
"is_pay": true
}
}
