I am writing an API with Node and Express, and use MongoDB as the database.
It has worked for a long time now, but today when I wrote some changes to a model, the server won't start anymore. I originally thought that a recent code change caused it, but even if I stash my changes and reset to a working state, the error occurs.
This is the error:
TypeError: pool.getAll is not a function
at MongoCR.auth (/location/of/project/node_modules/mongodb/node_modules/mongodb-core/lib/auth/mongocr.js:56:26)
at Server.auth (/location/of/project/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:1019:40)
at ReplSet.auth (/location/of/project/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/replset.js:572:17)
at ReplSet.auth (/location/of/project/node_modules/mongodb/lib/replset.js:438:23)
at authenticate (/location/of/project/node_modules/mongodb/lib/db.js:1319:21)
at Db.authenticate (/location/of/project/node_modules/mongodb/lib/db.js:1356:44)
at /location/of/project/node_modules/mongodb/lib/mongo_client.js:414:25
at /location/of/project/node_modules/mongodb/lib/db.js:221:5
at connectHandler (/location/of/project/node_modules/mongodb/lib/replset.js:335:7)
at g (events.js:260:16)
If I comment out all database connections the app runs. I've tried changing database, but it does not work either. I found this and this question and answer, and double checked versions and that all db-calls have callback-methods. I've used the last argument as the callback for calls that affect one entry, and toArray(function(err, result){})
when there are multiple entries returned.
Mongo version is 2.6.3, and I use the Node-mongodb driver.
I connect with
var mongo = require('mongodb').MongoClient;
var url = process.env.MONGODB || 'mongodb://localhost:27017/test';
var myCollection;
mongo.connect(url, function(err, db) {
if(err) console.log(err);
myCollection = db.collection('myCollection');
});
Then I have methods for e.g. find:
myCollection.find({}).toArray(function(err, result){
// work with result
});
I'm lost - thanks in advance.