-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
server/replset/mongos options are deprecated => documentation? #5442
Comments
+1 |
2 similar comments
+1 |
+1 |
+1 |
The message says that all of the server, replset, and mongos options have been moved to the top level of the options object. Simply move the settings from the mongoose.connect( 'mongodb://localhost/db',
{
useMongoClient: true,
server: {
poolSize: 2
},
promiseLibrary: global.Promise
}
); turns into mongoose.connect( 'mongodb://localhost/db',
{
useMongoClient: true,
poolSize: 2,
promiseLibrary: global.Promise
}
); |
Hello, Just for information, on my case I used an old version of |
Will add more details to the docs about thjs |
Fixing bug described in Automattic/mongoose#5442
@beeequeue I am still getting this warning message. Here is what I am doing options and connect const options = {
useMongoClient: true,
server: { socketOptions: { keepAlive: 300000, connectTimeoutMS: 30000 } },
replset: { socketOptions: { keepAlive: 300000, connectTimeoutMS: 30000 } }
};
mongoose.connect(<url>, options)
.then(() => {
logger.log('info', 'connected to mongodb');
})
.catch((error) => {
logger.log('info', 'error connecting to db: ' + error);
}); warning message the server/replset/mongos options are deprecated, all their options are supported at the top level of the options object [poolSize,ssl,sslValidate,sslCA,sslCert,sslKey,sslPass,sslCRL,autoReconnect,noDelay,keepAlive,connectTimeoutMS,socketTimeoutMS,reconnectTries,reconnectInterval,ha,haInterval,replicaSet,secondaryAcceptableLatencyMS,acceptableLatencyMS,connectWithNoPrimary,authSource,w,wtimeout,j,forceServerObjectId,serializeFunctions,ignoreUndefined,raw,promoteLongs,bufferMaxEntries,readPreference,pkFactory,promiseLibrary,readConcern,maxStalenessSeconds,loggerLevel,logger,promoteValues,promoteBuffers,promoteLongs,domainsEnabled,keepAliveInitialDelay,checkServerIdentity,validateOptions]
the server/replset/mongos options are deprecated, all their options are supported at the top level of the options object [poolSize,ssl,sslValidate,sslCA,sslCert,sslKey,sslPass,sslCRL,autoReconnect,noDelay,keepAlive,connectTimeoutMS,socketTimeoutMS,reconnectTries,reconnectInterval,ha,haInterval,replicaSet,secondaryAcceptableLatencyMS,acceptableLatencyMS,connectWithNoPrimary,authSource,w,wtimeout,j,forceServerObjectId,serializeFunctions,ignoreUndefined,raw,promoteLongs,bufferMaxEntries,readPreference,pkFactory,promiseLibrary,readConcern,maxStalenessSeconds,loggerLevel,logger,promoteValues,promoteBuffers,promoteLongs,domainsEnabled,keepAliveInitialDelay,checkServerIdentity,validateOptions] |
@sulhome Just move it too main options object like this const options = {
useMongoClient: true,
keepAlive: 300000,
connectTimeoutMS: 30000,
}; |
@tommarien but there is |
@sulhome both, as well as |
just put all the options in top level, it works. old format: new format (just one level): |
mongoose.connect( Happening here too. |
@CuAnnan the below should work. Promote your mongoose.connect(
mongoString,
Object.assign({
useMongoClient:true
}, mongoConf.db)
); |
原来是将 options 对象配置 提升到了顶级
变成
|
Hi there, options: {
db : {
safe: true
}
} This code can be located from https://github.com/angular-fullstack/generator-angular-fullstack/blob/ab8624002cd90aac100dbb6cc263d92f7f599588/templates/app/server/config/environment/index.js#L43 which still uses mongoose before 4.12, I want to upgrade it but cannot find any relevant migration info for this. Thanks for any pieces of advice! Cheers, |
@azachar here's some docs: http://mongoosejs.com/docs/connections.html#use-mongo-client . However, using |
Thank you very much for your response!
…Sent from my iPhone
On 10 Jan 2018, at 22:30, Valeri Karpov ***@***.***> wrote:
@azachar here's some docs: http://mongoosejs.com/docs/connections.html#use-mongo-client . However, using safe is no longer necessary because the mongodb driver uses acknowledged writes by default now, safe was a 2011-2012 construct to turn on acknowledged writes and journaling in one command, but it is now an anachronism. I would recommend just removing it entirely.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
+1 |
Do you want to request a feature or report a bug?
Documentation enhancement
What is the current behavior?
Using Mongoose 4.11.1 I get following deprecation warning:
What is the expected behavior?
Following the warning, I was searching the documentation about how to resolve this warning (http://mongoosejs.com/docs/connections.html#use-mongo-client) but didn't found anything about it aka anything about how I should migrate these options
Please mention your node.js, mongoose and MongoDB version.
Node.js v8.1.3
Mongoose 4.11.1
Mongodb v3.2.14
The text was updated successfully, but these errors were encountered: