gpt4 book ai didi

javascript - MongoDB Cursor 没有方法 'next'

转载 作者:可可西里 更新时间:2023-11-01 09:57:26 25 4
gpt4 key购买 nike

这些工作正常:

myCollection.find();
myCollection.findOne();

这不是:

           myCollection.find().next();
^
TypeError: Object #<Cursor> has no method 'next'

但是文档说:

cursor.next()

Returns: The next document in the cursor returned by the db.collection.find() method.

对我做错了什么有什么想法吗?

最佳答案

虽然相关,JavaScript Methods in MongoDBnative driver for Node.js 中的不同.

前者,包括cursor.next() ,组成了MongoDB自己的API,类似于关系数据库中的SQL命令。通过 mongo shell 连接时使用这些.

Node.js 驱动程序 API 中 cursor.next() 的等效项是 cursor.nextObject() .

关于javascript - MongoDB Cursor 没有方法 'next',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17799447/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com