Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deprecation warning `the server/replset/mongos/db options are deprecated` is showing

how to remove this warnings, after connecting to mongo using mongoose 5.2.17 with options server.ssl is enabled.

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]

like image 794
Juls1029 Avatar asked Oct 08 '18 06:10

Juls1029


1 Answers

From the warning message what I found out is well documented here.

It says, move the settings from the server, replset, and mongos keys up into the top level of the object.

// 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
  }
);

For more information refer options in mongoose docs.

like image 71
Vivek Molkar Avatar answered Nov 15 '22 20:11

Vivek Molkar