john-smilga/node-express-course

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

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.