gpt4 book ai didi

node.js - 显示弃用警告 `the server/replset/mongos/db options are deprecated`

转载 作者:可可西里 更新时间:2023-11-01 09:12:43 26 4
gpt4 key购买 nike

如何在使用带有选项 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.

它说,serverreplsetmongos 键的设置移动到对象的顶层.

// 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com