正在获取 node-mongodb-native 设置,所有内容都返回 null?
我无法让 node-mongodb-native 驱动程序正常运行。我已经安装了所有内容,所有测试都正确运行,但是当我尝试运行任何示例时,我在函数上收到空错误。例如:
类型错误:无法调用 null 的“删除”方法
Mongo 显示已建立连接,调用一个函数,然后连接关闭。我尝试过 mongodb 1.4.5、1.6.5 和 1.8.1,结果都相同。
我还应该做其他事情来运行示例吗?
I am having trouble getting the node-mongodb-native drivers to play nice. I've installed everything, all tests run correctly but when I try and run any of the examples I get a null error on the function. e.g.:
TypeError: Cannot call method 'remove' of null
Mongo shows that a connection is made, a function called then the connection closes. I have tried mongodb 1.4.5, 1.6.5 and 1.8.1 all with the same result.
Is there something else I should be doing to get the examples to run?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这意味着您正在尝试执行
remove
,但集合未正确初始化。我为 Node.JS + MongoDB + CloudFoundry 博客文章组装了一些示例代码< /a>. GitHub 上还有一些示例代码。该代码设计为无需 CloudFoundry 即可工作,只需在本地运行即可。
看一下执行基本查找的代码:
看一下
coll.find
,我假设coll
已正确初始化。它有可能未初始化。如果是这样,请检查err
变量并查看您得到的结果。还要检查上面级别的err
变量。This means that you are trying to do a
remove
but the collection did not initialize correctly.I assembled some sample code for a Node.JS + MongoDB + CloudFoundry blog post. There's also some sample code on GitHub. The code is designed to work without CloudFoundry and simply run locally.
Take a look at the code that does the basic find:
Take a look at
coll.find
, I'm assuming thatcoll
is correctly initialized. There's a chance that it may not be initialized. If so, check theerr
variable and see what you're getting. Also check theerr
variable at the level above that.