更新mongodb依赖项后发出警告 [英] Warning after updating mongodb dependency

查看:261
本文介绍了更新mongodb依赖项后发出警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've installed the latest version of winston-mongodb. I've noticed that the version of mongodb from winston-mongodb package has updated from 1.6.6 version to 2.0.7 version. After updating I got this warning:

不推荐使用server/replset/mongos选项,所有选项 在options对象的顶层受支持 [poolSize,ssl,sslValidate,sslCA,sslCert,sslKey,sslPass,自动重新连接,noDelay,keepAlive,connectTimeoutMS,socketTimeoutMS,reconnectTries,reconnectInterval,ha,haInterval,replicaSet,secondaryAcceptableLatencyMS,acceptableLatencywMS,Source,outObject, ,serializeFunctions,ignoreUndefined,raw,promoteLongs,bufferMaxEntries,readPreference,pkFactory,promiseLibrary,readConcern,maxStalenessSeconds,loggerLevel,logger,promoteValues,promoteBuffers,promoteLongs,domainsEnabled,keepAliveInitialDelay,checkServerOptionIdentity

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]

我该如何解决?有什么主意吗?

How can I solve this? Any idea?

推荐答案

根据错误消息;

the server/replset/mongos options are deprecated, all their options are supported at the top level of the options object

因此,解决该问题的方法只是将服务器,replset,socketOptions,mongos和任何其他层次结构选项中的设置选项移到对象的顶层.

so, solution for the problem is simply moving the setting options from the server, replset, socketOptions, mongos and any other hierarchy options up into the top level of the object.

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依赖项后发出警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆