Removal of mongoose.connect() options for Mongoose 6.x
Closed this issue · 0 comments
Description
On migrating/using Mongoose 6.x, one may get deprecating warning options due to usage of following options when connecting to the database through mongoose.connect()
: useNewUrlParser, useUnifiedTopology, useFindAndModify, and useCreateIndex.
Files
- Excluding 01-node-tutorial and 02-express-tutorial
- All projects with the path: /final/db/connect.js
- 11-auth-workflow/final/server/db/connect.js
To Reproduce
Install the npm package for Mongoose 6.x. Implement connect.js as in the final folder, with options.
Fix
As per https://mongoosejs.com/docs/migrating_to_6.html: useNewUrlParser, useUnifiedTopology, useFindAndModify, and useCreateIndex are no longer supported options. Mongoose 6 always behaves as if useNewUrlParser, useUnifiedTopology, and useCreateIndex are true, and useFindAndModify is false. Please remove these options from your code.
The options need to be removed from the code, to resolve the issue.