These work fine:
myCollection.find();
myCollection.findOne();
This does not:
myCollection.find().next();
^
TypeError: Object #<Cursor> has no method 'next'
But documentation says:
cursor.next()
Returns: The next document in the cursor returned by the db.collection.find() method.
Any ideas on what I'm doing wrong?
While related, the JavaScript Methods in MongoDB are not the same as those in the native driver for Node.js.
The former, including cursor.next(), make up MongoDB's own API and are similar to SQL commands in relational databases. Use these when connected through the mongo shell.
The equivalent of cursor.next() within the Node.js driver API is cursor.nextObject().
Just to note that cursor.next() replaces nextObject() in 2.0 and is available.