如何在使用带有选项 server.ssl 的 mongoose 5.2.17 连接到 mongo 后删除此警告。
the server/replset/mongos/db 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,keepAliveInitialDelay,connectTimeoutMS,family,socketTimeoutMS,reconnectTries,reconnectInterval,ha,haInterval,replicaSet,secondaryAcceptableLatencyMS,acceptableLatencyMS,connectWithNoPrimary,authSource,w,wtimeout,j,forceServerObjectId,serializeFunctions,ignoreUndefined,raw,bufferMaxEntries,readPreference,pkFactory,promiseLibrary,readConcern,maxStalenessSeconds,loggerLevel,logger,promoteValues,promoteBuffers,promoteLongs,domainsEnabled,checkServerIdentity,validateOptions,appname,auth,user,password,authMechanism,compression,fsync,readPreferenceTags,numberOfRetries,auto_reconnect,minSize,monitorCommands,retryWrites,useNewUrlParser]
最佳答案
从警告消息中我发现的内容有据可查here.
它说,将 server
、replset
和 mongos
键的设置移动到对象的顶层.
// The options inside the `server` attributes are moved to its parents.
// Same happens to `replset` and `mongos`
// Change this
mongoose.connect( 'mongodb://localhost/db',
{
useMongoClient: true,
server: {
poolSize: 2
},
promiseLibrary: global.Promise
}
);
// To this
mongoose.connect( 'mongodb://localhost/db',
{
useMongoClient: true,
poolSize: 2,
promiseLibrary: global.Promise
}
);
有关更多信息,请参阅 options in mongoose docs.
关于node.js - 显示弃用警告 `the server/replset/mongos/db options are deprecated`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52696224/