【发布时间】:2012-07-26 15:24:32
【问题描述】:
我在玩 mongodb 并将一些测试数据 {name:"david"} 输入到“用户”集合中。我使用 mongo shell 通过键入验证数据在 MongoDB 中
db.users.find()
结果:
{ "name":"david" }
在 node.js 脚本中,如下代码:
db.open(function(err, db) {
if (!err) {
console.log("db opened!");
}
else {
console.log(err);
}
db.collection('users', function(err, collection) {
collection.find({}, function(err, cursor) {
cursor.each(function(err, item) {
console.log(item);
});
});
});
db.close();
});
不返回任何结果
我没有发现任何错误,也没有错误返回。请指教
【问题讨论】: