需要查詢:
數組長度大於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()
記錄,備忘……