我正在使用MongoClient.connect()打开连接,并且出现以下错误...
/node_modules/mongodb/lib/operations/mongo_client_ops.js:466
throw err;
^
TypeError: final argument to `executeOperation` must be a callback
但是,我正在遵循文档中规定的args格式...
MongoClient.connect(url, options, callback)
我的确切代码是:
MongoClient.connect(url, { useNewUrlParser: true }, (err, db) => {
if (err) {
console.log('there was an error ', err);
} else {
console.log('established connection');
}
...some query stuff...
db.close();
}
MongoDb版本:3.1.6
有什么线索可以解释为什么我会出现此错误?