Skip to content

Conversation

@KirtiGautam620
Copy link

Ensure global Mongoose options like autoCreate are inherited by additional connections

Related Issue:
Fixes #15748 – Global autoCreate option not applied to models on createConnection()

Description:
This PR addresses an issue where global Mongoose options, such as autoCreate, were not inherited by connections created via mongoose.createConnection(). Previously, only models on the default connection respected these global settings, causing inconsistent behavior between default and additional connections.

Changes Made:

  • Updated the Connection constructor (lib/connection.js) to merge global options from base.options into this.options using:
    this.options = Object.assign({}, base.options);

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.

Global autoCreate option not applied to models on createConnection()

1 participant