我希望最终能够在Windows上使用node js使用mongo db。在命令行上键入node app.js时,当前安装出现错误。
const MongoClient = require('mongodb').MongoClient;
// replace the uri string with your connection string.
const uri = "mongodb+srv://shahid:<PASSWORD>@cluster0-1q7ty.mongodb.net/test"
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("test").collection("devices");
// perform actions on the collection object
client.close();
});