How to set useMongoClient (Mongoose 4.11.0)?

Solution 1:

This is how you use useMongoClient:

mongoose.connect('mongodb://localhost/advisorDemoTestDB', { useMongoClient: true })

Solution 2:

Add { useMongoClient: true } as another argument to connect or createConnection method, its depends on version of mongoose you are using.

// Using `mongoose.connect`...
var promise = mongoose.connect('mongodb://localhost/myapp', {
  useMongoClient: true,
  /* other options */
});
// Or `createConnection`
var promise = mongoose.createConnection('mongodb://localhost/myapp', {
  useMongoClient: true,
  /* other options */
});

Solution 3:

mongoose.connection.openUri('mongodb://127.0.0.1/camp_v12')

has anyone tried this? my deprecated warning disappeared when i use this, it was from the documentation

http://mongoosejs.com/docs/connections.html