gpt4 book ai didi

mongodb - 更新 mongodb 依赖后出现警告

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

我已经安装了最新版本的 winston-mongodb。我注意到 winston-mongodb 包中 mongodb 的版本已经从 1.6.6 版本更新到 2.0.7 版本。更新后我得到了这个警告:

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,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]

我该如何解决这个问题?有什么想法吗?

最佳答案

根据错误提示;

server/replset/mongos 选项已弃用,它们的所有选项都在选项对象的顶层受支持

因此,该问题的解决方案只是将设置选项从服务器、replset、socketOptions、mongos 和任何其他层次结构选项向上移动到对象的顶层。

mongoose.connect( 'mongodb://localhost/db',
{
useMongoClient: true,
server: {
ssl: true,
socketOptions: {
keepAlive: 300000,
connectTimeoutMS: 30000
},
auto_reconnect: true,
reconnectTries: 300000,
reconnectInterval: 5000
},
promiseLibrary: global.Promise
}
);

change it to;

mongoose.connect( 'mongodb://localhost/db',
{
useMongoClient: true,
poolSize: 2,
ssl: true,
keepAlive: 300000,
connectTimeoutMS: 30000,
autoReconnect: true,
reconnectTries: 300000,
reconnectInterval: 5000,
promiseLibrary: global.Promise
}
);

希望对您有所帮助!谢谢,

关于mongodb - 更新 mongodb 依赖后出现警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42409258/

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