【发布时间】:2017-08-16 03:32:39
【问题描述】:
您好,我想在 mongodb 的 features 数组中返回数组计数小于 2 的所有集合。我尝试使用$size,但这是不可能的。
我不想得到结果并循环每个features 并计算它。我想返回productId 123,因为它在一个特征数组中的计数为 1。请以以下文档为例:
{
"productId" : 123.0,
"features" : [
{
"a" : true
},
{
"a" : true,
"b" : true
}
]
},
{
"productId" : 456.0,
"features" : [
{
"a" : true,
"b" : true
},
{
"a" : true,
"b" : true
}
]
}
【问题讨论】:
标签: javascript arrays mongodb mongodb-query aggregation-framework