(基础库版本不知道啥东西,随便写的!)
limit函数在聚合查询时,不知何原因,返回的记录数不正确。
limit设置为500时:
db.collection('persons')
.aggregate()
.skip(0)
.limit(500)
.match({department: '音乐系', majorLevel: '中专'})
.project({
_id: 1,
department: $.ifNull(['$department', '']),
majorLevel: $.ifNull(['$majorLevel', '']),
})
.end()
limit设置为5000时:
db.collection('persons')
.aggregate()
.skip(0)
.limit(5000)
.match({department: '音乐系', majorLevel: '中专'})
.project({
_id: 1,
department: $.ifNull(['$department', '']),
majorLevel: $.ifNull(['$majorLevel', '']),
})
.end()
match放在limit之前
.match({department: '音乐系', majorLevel: '中专'}) .limit(500)