我的JSON数据结构如下
"ArticleInfo": [{
"InfArt": {
"langs": [{
"code": 1,
"text": "Technische Information"
},
{
"code": 4,
"text": "Technical Information"
},
{
"code": 6,
"text": "Informations techniques"
},
]
}
}]
跟随
filter
我编写的shell命令的用法如下
db.article.aggregate(
{
$match: {
"articleNumber": "123123"
},
},
{
$project: {
'ArticleInfo.InfArt.langs': {
$filter: {
input: "$ArticleInfo.InfArt.langs",
as: "item",
cond: { $eq: [ '$$item.code', 4 ] }
}
}
}
}
)
但是
$eq
看起来不像是工作,它给出了一个空列表
我想知道
langs
数组,我写错了吗?