在使用带选项server.ssl的mongoose 5.2.17连接到mongo之后,如何消除此警告。
不建议使用server / replset / mongos / db选项,所有选项 在options对象的顶层受支持 [poolSize,ssl,sslValidate,sslCA,sslCert,sslKey,sslPass,sslCRL,自动重新连接,noDelay,keepAlive,keepAliveInitialDelay,connectTimeoutMS,family,socketTimeoutMS,reconnectTries,reconnectInterval,ha,haInterval,repliacSetable,AcceptL, ,wtimeout,j,forceServerObjectId,serializeFunctions,ignoreUndefined,raw,bufferMaxEntries,readPreference,pkFactory,promiseLibrary,readConcern,maxStalenessSeconds,loggerLevel,logger,promoteValues,promoteBuffers,promoteLongs,domainsEnabled,checkServerIdentity,authentication,validateOptions, ,压缩,fsync,readPreferenceTags,重试次数,auto_reconnect,minSize,monitorCommands,retryWrites,useNewUrlParser]
答案 0 :(得分:1)
从警告消息中我发现,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.