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

Remove default connection if setting createInitialConnection to false after Mongoose instance created #14679

Merged
merged 7 commits into from
Jun 24, 2024

Conversation

vkarpov15
Copy link
Collaborator

Summary

Right now there's always a default mongoose.connection. We added a createInitialConnection option that prevents new Mongoose instances from creating a default connection, but that doesn't apply to existing Mongoose instances, including the default one. So there's no way to really "delete" the default connection in the API.

With this PR, mongoose.set('createInitialConnection', false) will also remove the default connection, presuming it isn't connected and there are no models already on it.

Examples

lib/mongoose.js Outdated Show resolved Hide resolved
test/index.test.js Outdated Show resolved Hide resolved
@hasezoey hasezoey added this to the 8.5 milestone Jun 24, 2024
test/index.test.js Outdated Show resolved Hide resolved
Co-authored-by: hasezoey <hasezoey@gmail.com>
@vkarpov15 vkarpov15 merged commit cd11105 into 8.5 Jun 24, 2024
46 checks passed
@hasezoey hasezoey deleted the vkarpov15/gh-8302 branch June 25, 2024 08:40
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.

2 participants