如何检测 mongoDB 查询已获取所有记录?

How to detect the mongoDB query has fetched all the records?

我正在使用以下查询从 mongoDB

中获取数据
collection.find({_id: "34534534"}, { cont: {$slice:[count,10]} })

每次我调用这个查询时 returns 10 条记录的数据和计数是不断变化的变量,如 -30、-40 等。如何知道查询已达到最后10记录?

collection.find({_id: "34534534"}, { cont: {$slice:[count,11]} })

只需将限制更改为 11。经过的时间几乎等于您的代码,但让您有机会查看是否还有更多记录。