Connects without a hitch, but on insert()
throws me this error.
var MongoClient = require('mongodb').MongoClient;
const assert = require('assert');
var url = 'mongodb://____:[email protected]:25565/heroku_w268n9pj';
MongoClient.connect(url, function(err, client) {
assert.equal(null, err);
db = client.db('temp');
console.log("connected!");
const collection = db.collection('temp');
collection.insert([{
something: please
}
});
I saw some other answers regarding mLab accounts and credentials, but I just created a new admin account for this. Frustrating because it was working previously with v2.3.
heroku_w268n9pj
. so trydb = client.db('heroku_w268n9pj')
. Otherwise, you're trying to run commands on thetemp
database - which you do not have access to. – Kiowadb
object was created automatically from the connection string. Whereas now you need to specify the db name yourself. Make sure it's the same one as in the connection string. – Kiowa