我在 Raspberry Pi(运行最新的 Raspbian)上使用 MongoDB 版本 2.4.14。我有一个简单的测试文件试图让 mongo 工作:
let url = 'mongodb://172.20.0.239:27017/'
var MongoClient = require('mongodb').MongoClient;
MongoClient.connect(url,{ useUnifiedTopology: true }, function(err, db) {
if (err) throw err;
var dbo = db.db(<database>);
var cursor = dbo.collection("Players").find();
if (cursor == null) {
console.log('cursor nulo');
} else {
console.log('cursor n nulo');
var strArray = [];
cursor.each(function (err, item) {
if(item!=null){
strArray.push(item.datetime+' '+item.onlineUsers);
console.log(item.datetime+' '+item.onlineUsers);
}
else{
dbo.close();
}
});
}
});
我收到错误消息:
MongoServerSelectionError: Server at 172.20.0.239:27017 reports maximum wire version 0, but this version of the Node.js Driver requires at least 2 (MongoDB 2.6)
我的代码有问题吗?