计数数字大于MongoDB阵列中的某个数字
{
"_id" : ObjectId(""),
"CustomerId" : 13038,
"AT" : ISODate("2021-12-01T04:00:00.000Z"),
"dwell" : [
7,
6,
12,
6 ]
},
{
"_id" : ObjectId(""),
"CustomerId" : 12036,
"AT" : ISODate("2021-12-01T04:00:00.000Z"),
"dwell" : [
15,
3,
12
]
}
在这些文档中,我只想获取大于10的停留数字的计数。
例如:
{"CustomerId": 13038, "Count": 1} //because only 12 bigger than 10
{"CustomerId": 12036, "Count": 2}
{
"_id" : ObjectId(""),
"CustomerId" : 13038,
"AT" : ISODate("2021-12-01T04:00:00.000Z"),
"dwell" : [
7,
6,
12,
6 ]
},
{
"_id" : ObjectId(""),
"CustomerId" : 12036,
"AT" : ISODate("2021-12-01T04:00:00.000Z"),
"dwell" : [
15,
3,
12
]
}
In these documents, I only want to get the count of the numbers in the dwell which are greater than 10.
For Example:
{"CustomerId": 13038, "Count": 1} //because only 12 bigger than 10
{"CustomerId": 12036, "Count": 2}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
$ size size
和
:示例mongoplayground
You could do something like this using
$size
and$filter
:Example MongoPlayground