Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用以下查询从 mongoDB 获取数据
collection.find({_id: "34534534"}, { cont: {$slice:[count,10]} })
每次我调用此查询时,它都会返回 10 条记录的数据,并且 count 是不断变化的变量,如 -30、-40 等。如何知道查询已达到最后 10 条记录?
collection.find({_id: "34534534"}, { cont: {$slice:[count,11]} })
只需将限制更改为 11。经过的时间几乎等于您的代码,但让您有机会查看是否有更多记录。