【发布时间】:2019-01-02 09:24:42
【问题描述】:
nodejs 成功连接到 atlas,但是当我尝试控制台记录数据时出现错误
const uri = "mongodb+srv://daww:pass@cluster0-shard-00-00-fmmcx.mongodb.net/admin"
MongoClient.connect(uri, function(err, client) {
if(err) {
console.log('Error occurred while connecting to MongoDB Atlas...\n',err);
}
console.log('Connected...');
const collection = client.db("star").collection("clc").find({}).toArray(function(err,result){
if(err) throw err;
console.log(result)
});
client.close();
});
我期待一个包含数据库所有内容的 json 对象,但是我收到以下错误
MongoNetworkError: connection destroyed, not possible to instantiate cursor
【问题讨论】:
标签: javascript node.js mongodb