I am using Mongoose with my Node.js app and this is my configuration:
mongoose.connect(process.env.MONGO_URI, {
useNewUrlParser: true,
useUnifiedTopol
If your code includes createConnetion for some reason (In my case I'm using GridFsStorage), try adding the following to your code:
options: {
useUnifiedTopology: true,
}
just after file, like this:
const storage = new GridFsStorage({
url: mongodbUrl,
file: (req, file) => {
return new Promise((resolve, reject) => {
crypto.randomBytes(16, (err, buf) => {
if (err) {
return reject(err);
}
const filename = buf.toString('hex') + path.extname(file.originalname);
const fileInfo = {
filename: filename,
bucketName: 'uploads'
};
resolve(fileInfo);
});
});
},
options: {
useUnifiedTopology: true,
}
})
If your case looks like mine, this will surely solve your issue. Regards