Reputation: 6936
I am using mongodb-3.6.0.
My express code is
var promise = mongoose.connect('mongodb://localhost/myapp', {
useMongoClient: true
});
On running the app I am getting the options [useMongoClient] is not supported
. My mongoose version in ^5.0.0-rc0
.
Please help.
Upvotes: 16
Views: 22356
Reputation: 1
Here's what works for me node.js v14 + mongoose v6
mongoose.connect("mongodb://localhost:27017/your-db-name", {
auth: {
username: "user",
password: "password",
},
authSource: "admin",
});
Upvotes: 0
Reputation: 1
No Need of useMongoClient
Flag Now with Newer version of mongoose.
{
useMongoClient : true
}
Upvotes: 0
Reputation: 821
The answer to this is pretty simple just remove { useMongoClient: true }
flag from your code since the option is no longer necessary in mongoose 5.x and use
{ useNewUrlParser: true }
since you might get a message that the current URL string parser is deprecated.
Upvotes: 5
Reputation: 1
const mongoose = require('mongoose');
mongoose.connect('mongodb://127.0.0.1:27017/qunar', { useMongoClient: true });
mongoose.Promise = global.Promise;
module.exports = mongoose
answer:☟
Delete the first line of code { useMongoClient: true }
and then restart the server
Upvotes: 0
Reputation: 159
mongoose 5 doesn't require useMongoClient anymore.
mongoose.connect('mongodb://localhost/DB_name');
is enough. You can check for the documentation of "Mongoose 5" here
Upvotes: 7
Reputation: 764
There is not much documentation about this yet as Mongoose 5 is in release candidate stage but with mongoose 5 you don't need to provide useMongoClient option. Mongoose 5 is using Mongo client by default. So just remove this option.
Upvotes: 26