when I run the code by "node app.js" command this error is showing
(node:2509) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
The useNewUrlParser Option DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient. connect. The MongoDB Node.
the useCreateIndex option ensures that you are using the new function calls. Reference: https://mongoosejs.com/docs/connections.html#options https://mongoosejs.com/docs/deprecations.html. Follow this answer to receive notifications.
How to use it. The unified topology is available now behind the useUnifiedTopology feature flag. You can opt in to using it by passing the option to your MongoClient constructor: const client = MongoClient('mongodb://localhost:27017', { useUnifiedTopology: true });
You need to pass { useNewUrlParser: true }
option to mongoose.connect() method. Your code should look similar to the snippet below.
mongoose.connect('mongodb://user:[email protected]:27017/dbname', { useNewUrlParser: true })
to avoid this problem use this
MongoClient.connect('mongodb://user:[email protected]:port/dbname', { useNewUrlParser: true })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With