{
s_id:"001",
goods:[
{type:"01",name:"aaa",price:10},
{type:"02",name:"bbb",price:15}
]
},
{
s_id:"002",
goods:[
{type:"01",name:"ccc",price:10},
{type:"02",name:"ddd",price:15}
]
}
db.collection("goods").where(_.and([{
s_id: _this.data.s_id
}, {
goods: _.elemMatch({
type: _this.data.value
})
}])).get({
success: (res => {
return res
})
})
上面两条数据是我goods集合里的两条数据,我就想查s_id等于某个值里面的goods数组条件满足type等于某个值的结果,这样写貌似不行
试试:
.aggregate()
.unwind('goods')
.match({...})