Server Discovery And Monitoring engine is deprecated

后端 未结 23 1250
执笔经年
执笔经年 2020-12-01 00:54

I am using Mongoose with my Node.js app and this is my configuration:

mongoose.connect(process.env.MONGO_URI, {
   useNewUrlParser: true,
   useUnifiedTopol         


        
23条回答
  •  执念已碎
    2020-12-01 00:56

    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

提交回复
热议问题