0
votes

I'm trying to connect my NodeJS project to mongoose by using this statement :-

var mongoose = require("mongoose");
mongoose.connect('mongodb://localhost:27017/football',  {useNewUrlParser: true});

However on running the given .js file I am getting the following error :-

(node:3438) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.

I tried adding {useUnifiedTopology : true} to the parameters, but then it shows error for having 3 arguments

How to solve this problem

1
The second argument is an options object, add both options fields in a single object.Joe
As @Joe said, you need to pass both key in a same object which is second argument like mongoose.connect('mongodb://localhost:27017/football', { useNewUrlParser: true, useUnifiedTopology: true });Arif Khan

1 Answers

1
votes

You need to pass all the (options) parameters within a single object, like the documentation says. Here's the code:

mongoose.connect('mongodb://localhost:27017/football', {
   useNewUrlParser: true,
   useUnifiedTopology: true

   // Other parameters here...
});