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?
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?
Share Improve this question asked Jul 23, 2013 at 0:06 JapandroidJapandroid 231 silver badge4 bronze badges 2-
1
What is
myCollection
(how did you create it)? What mongodb driver do you use? Which version? Could you provide an SSCCE? – Zeta Commented Jul 23, 2013 at 0:19 -
There's a
nextObject
on the cursor in the MongoDB Node.JS driver: mongodb.github.io/node-mongodb-native/api-generated/…, but nonext
. – WiredPrairie Commented Jul 23, 2013 at 0:32
2 Answers
Reset to default 5While 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 mands 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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745223296a4617347.html
评论列表(0条)