-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Description
Do you want to request a feature or report a bug?
Feature
What is the current behavior?
When you connect to MongoDB, you provide a dbName option to specify which database to connect to. This is handled here
Lines 604 to 608 in 3e9faef
| parseConnectionString(uri, options, (err, parsed) => { | |
| if (err) { | |
| return reject(err); | |
| } | |
| this.name = dbName != null ? dbName : get(parsed, 'auth.db', null); |
This was added in #6106 in response to SRV connection strings lacking a database name, and thus the dbName workaround was added.
What is the expected behavior?
Now when testing with Atlas connection strings, it looks like we have the ability to specify a default database in the connection string - and parseConnectionString() successfully parses it.
The spec doesn't show this option, however Atlas uses it and even shows an example of defaulting to a test database in their Driver Examples documentation.
Thus, we believe the logic here should be (in this order):
- if
dbNameis provided in the options, use it - if the database name is provided in the connection string (parsed as
defaultDatabase), use it - if neither of the above are provided, default to the authorization database
Currently there is no step 2.
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node.js: 10.15
Mongoose: 5.4
MongoDB: 3.6
I'm working on a PR right now to add this logic and update these docs