2017-02-23 81 views
3

我已安裝最新版本的winston-mongodb。我注意到版本mongodbwinston-mongodb包已經從1.6.6版本更新到2.0.7版本。更新後,我得到這個warning更新mongodb依賴關係後發出警告

服務器/複製集/ mongos選項已被棄用,所有的選項 在選項的頂層被支持的對象 [poolSize,SSL,sslValidate,sslCA,的sslcert,sslKey ,sslPass,autoReconnect的,NODELAY,的keepAlive,connectTimeoutMS,socketTimeoutMS,reconnectTries,reconnectInterval,哈,haInterval,replicaSet,secondaryAcceptableLatencyMS,acceptableLatencyMS,connectWithNoPrimary,authSource,W,wtimeout,J,forceServerObjectId,serializeFunctions,ignoreUndefined,生,promoteLongs,bufferMaxEntries,readPreference ,pkFactory,promiseLibrary,readConcern,maxStalenessSeconds,loggerLevel,logger,promoteValues,promotebuffers,promoteLongs,domainsEnabled,keepAliveInitialDelay,checkServerIdentity,validateOptions]

我該如何解決這個問題?任何想法?

回答

1

根據錯誤信息;

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

所以,對於問題的解決方案是簡單地移動從服務器複製集,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, 
    useMongoClient: true, 
    promiseLibrary: global.Promise 
    } 
); 

希望它有幫助! 謝謝,