-
Type: Bug
-
Resolution: Gone away
-
Priority: Blocker - P1
-
None
-
Affects Version/s: 4.0.0
-
Component/s: Shell
-
None
It seems setting a limit(1) on a cursor will cause it to return null on `next()` even if there is a document to return IF you call 'hasNext()' before calling next(). It will return true for `hasNext()`.
Steps to recreate:
$ node --experimental-repl-await > const m = require('mongodb'); const c = await m.MongoClient.connect('mongodb://127.0.0.1:27017', { useUnifiedTopology: true }) // or wherever you have a db > await c.db('test').collection('coll').insertMany([{x: 1}, {x: 2}, {x: 3}]) > const cursor = c.db('test').collection('coll').find() > const cursor2 = c.db('test').collection('coll').find().limit(1) > await cursor.hasNext() --> true > await cursor2.hasNext() --> true > await cursor.next() --> { x: 1 } > await cursor2.next() ------> THIS RETURNS NULL, IT SHOULD RETURN THE DOC
- is depended on by
-
MONGOSH-467 Update driver to 4.0
- Closed