Open glassdimly opened 5 years ago
This is our code that we were using to connect to the mongo-mock, which works find in mongodb:
MongoClient.connect(process.env.MONGODB_CONFIG) | ^ 63 | .then(client => { 64 | mongo = client.db('myDb');
The problem was that mongo was depending on us passing in a dbname as the path parameter of the URL:
MongoClient.connect = function(url, options, callback) { ... url = urlparse(url); ... var dbname = url.pathname.replace(/^\//, ''); return new Db(dbname, server).open(callback);
...We were not passing in dbname.
The workaround was this:
MongoClient.connect(process.env.MONGODB_CONFIG + '/myDb') .then(client => { mongo = client;
...That is, I needed to send the db in as a string.
This is our code that we were using to connect to the mongo-mock, which works find in mongodb:
The problem was that mongo was depending on us passing in a dbname as the path parameter of the URL:
...We were not passing in dbname.
The workaround was this:
...That is, I needed to send the db in as a string.