Error inserting into databases on atlas using options for connection creditials
"mongoose": "^5.2.13" NodeJS - v8.11.4 Mongodb - MongoDB shell version v3.6.1 Do you want to request a feature or report a bug? Bug report What is the current behavior? When saving data into database, connecting to the database works perfectly, I get the result of "MongoError: user is not allowed to do action [insert] on [database]" - this seems to be a issue with passing the basic uri with no options attached to it and options added via the option object parameter.
If the current behavior is a bug, please provide the steps to reproduce.
private async init() {
const options = {
authSource: 'admin',
useNewUrlParser: true,
user: settings.MongoUser,
pass: settings.MongoPwd,
dbName: 'UserAccounts',
keepAlive: 300000,
poolSize: 10,
ssl: true,
replicaSet: 'replicaSetName'
}
await mongoose.connect("mongodb+srv://addresstoatlasDB.net/", options)
.then((db) => {
console.log('Connected to mongoDB');
this._connection = db;
})
.catch((err) => {
console.log('Could not connect to mongoDB');
throw new Error(err);
});
}
What is the expected behavior? Expected behavior is for json data passed through to be saved to the database and not rejected as outlined above.
@joshuaanthonydeleon this should be fixed as of 5.2.16 ( related to #6881 ), can you upgrade to mongoose@latest and verify?
@lineus I've updated to package 5.2.18 and the error still persists. Is there additional info I can give to help?
@joshuaanthonydeleon you're right, I don't think the underlying driver bug was fixed as I can still reproduce this with the latest version of the native driver and useNewUrlParser = true.
I'm going to reopen #6881 and I've already reached out the native driver folks about the issue here
@lineus thanks for the link. I'll be following along as well.
I'm going to close this since we have #6881 opened back up. Apologies for closing that one without explicitly testing the native driver fix. Thanks for pointing it out @joshuaanthonydeleon !