Mongo Db .skip() Return 值
Mongo Db .skip() Return values
嗨,一个快速的理论问题,
When mongodb returns set after using a command like
db.collection.find().skip(1000)
是只return从第 1000 个对象到集合的末尾,还是return集合中的每个对象,但从第 1000 个对象开始,类似于循环队列。
我问的唯一原因是因为在我 运行 我的数据库上执行以下命令后,我得到了这些结果。
>>db.mycollection.find().skip(33405000).count()
>>393245869
>>db.mycollection.find().count()
>>393245869
谢谢!
现在你的问题更有趣了。
从官方 MongoDB 文档您可以阅读:
By default, the count() method ignores the effects of the
cursor.skip() and cursor.limit(). Set applySkipLimit to true to
consider the effect of these methods.
试试这个:
db.collection.find().skip(33405000).count({applySkipLimit:true})
更多信息请看cursor.count
嗨,一个快速的理论问题,
When mongodb returns set after using a command like
db.collection.find().skip(1000)
是只return从第 1000 个对象到集合的末尾,还是return集合中的每个对象,但从第 1000 个对象开始,类似于循环队列。
我问的唯一原因是因为在我 运行 我的数据库上执行以下命令后,我得到了这些结果。
>>db.mycollection.find().skip(33405000).count()
>>393245869
>>db.mycollection.find().count()
>>393245869
谢谢!
现在你的问题更有趣了。 从官方 MongoDB 文档您可以阅读:
By default, the count() method ignores the effects of the cursor.skip() and cursor.limit(). Set applySkipLimit to true to consider the effect of these methods.
试试这个:
db.collection.find().skip(33405000).count({applySkipLimit:true})
更多信息请看cursor.count