Reputation:
I am getting the following error in my terminal:
if (VALID_OPTIONS.indexOf(key) === -1) throw new Error(`\`${key}\` is an invalid option.`);
Here is my code:
And this is the error that I am getting:
Upvotes: 3
Views: 142
Reputation: 3126
The actual error you are getting is the following:
Error: 'useCreateIndex' is an invalid option.
Which is caused by line 31:
mongoose.set("useCreateIndex", true);
useCreateIndex
in Mongoose 6 and above always defaults to true and cannot be set.
From the docs:
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.
For future reference, the actual error is denoted by the Error:
keyword and everything after it, the part above just indicates what code invoked an error to be thrown manually.
Upvotes: 2