admin管理员组文章数量:1414874
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.
本文标签: javascriptMongoDB Cursor has no method 39next39Stack Overflow
版权声明:本文标题:javascript - MongoDB Cursor has no method 'next' - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745223295a2648493.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论