I am using MongoDB version 2.4.14 on a Raspberry Pi (running the latest Raspbian). I have a simple test file trying to get mongo to work:
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();
}
});
}
});
I am getting the error:
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)
Is there something wrong with my code?