mongodb尝试从将代码连接到数据库的网站运行该函数时发生错误。
const MongoClient = require('mongodb')
const client = new MongoClient(uri, { useNewUrlParser: true });
client.connect(err => {
const collection = client.db("test").collection("devices");
// perform actions on the collection object
client.close();
});
Run Code Online (Sandbox Code Playgroud)
错误是:
client.connect(err => {
^
TypeError: client.connect is not a function
Run Code Online (Sandbox Code Playgroud)
我已经mongodb安装了 vianpm和 uri 定义为他们给出的字符串。我还需要什么吗?