2 回答
![?](http://img1.sycdn.imooc.com/545845b40001de9902200220-100-100.jpg)
TA贡献1841条经验 获得超3个赞
试试这个查询
db.getCollection('db').aggregate(
{ "$addFields": {
"class":
{
"$filter": {
"input": "$class",
"as": "sn",
"cond": {
"$and": [
{ "$eq": [ "$$sn.name", "class one" ] },
]
}
}
}
}}
)
![?](http://img1.sycdn.imooc.com/5458463b0001358f02200220-100-100.jpg)
TA贡献2003条经验 获得超2个赞
db.getCollection('db').aggregate([{
"$unwind":"$class"
},{
"$match":{
"class.name":"class one"
}
},{
"$group":{
"_id":null,
"result":{
"$push":"$class"
}
}
},{
"$project":{
"_id":0
}
}])
添加回答
举报