Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(connections): Adds default database connection string support (#8354) #8355

Merged
merged 3 commits into from Nov 18, 2019
Merged

feat(connections): Adds default database connection string support (#8354) #8355

merged 3 commits into from Nov 18, 2019

Conversation

zachazar
Copy link
Contributor

Summary
This solves #8354. It appears that previously SRV connection strings didn't allow for default databases to be in the uri. I'm not sure if that changed recently, but when connecting to our Atlas clusters we are able to specify the default database in the string.

This PR changes the logic when assigning the database name (as outlined in #8354) to look for options.dbName, then look for the default database in the connection string, then fallback to the auth db.

Examples

mongoose.connect('mongodb+srv://<username>:<password>@cluster0.mongodb.net/defaultDatabase?w=majority')

// => results in a connection with `db.name === defaultDatabase`

@zachazar zachazar marked this pull request as ready for review November 18, 2019 19:08
@vkarpov15 vkarpov15 added this to the 5.7.12 milestone Nov 18, 2019
Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants