MongoParseError: options usecreateindex, usefindandmodify are not supported

The error is because of the new version of the mongoose i.e version 6.0.6.

useNewUrlParseruseUnifiedTopologyuseFindAndModify, and useCreateIndex are no longer supported options. Mongoose 6 always behaves as if useNewUrlParseruseUnifiedTopology, and useCreateIndex are true, and useFindAndModify is false. Please remove these options from your code.

// No longer necessary:
mongoose.set('useFindAndModify', false);

await mongoose.connect('mongodb://localhost:27017/test', {
  useNewUrlParser: true, // <-- no longer necessary
  useUnifiedTopology: true // <-- no longer necessary

Leave a Reply