This is frustrating. No clues why I got this error while documentation still has it. Please help!
My code to connect MongoDB with mongoose.
const mongoose = require('mongoose');
const connectDB = async () => {
try {
const conn = await mongoose.connect(process.env.MONGO_URI, {
useNewUrlParser: true,
useCreateIndex: true,
useUnifiedTopology: true
});
console.log(`MongoDB Connected: ${conn.connection.host}`.cyan.underline.bold);
} catch (err) {
console.log(`Error: ${err.message}`.red);
process.exit(1);
}
}
module.exports = connectDB;
Error: option usecreateindex is not supported
Documentation says useCreateIndex is the updated method.