版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/LLLLLiSHI/article/details/88397379
需要查询:
数组长度大于0的数据
db.collection.find({
$where: "this.array.length > 0"
})
.limit(100)
然而此时只能查询数据的详情,不能进行计数统计,即count()
因为下边的会报错:
db.collection.find({
$where: "this.array.length > 0"
})
.limit(100).count()
故,采取减法:总数-等于0的数量=大于0的数量
以下查询等于0的数量:
db.collection.find({
"array": {$size: 0}
})
.limit(100).count()
记录,备忘……