Current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
(Use node --trace-warnings ...
to show where the warning was created)
My code in db.js
const mongoose = require(‘mongoose’);
const winston = require(‘winston’);
const config = require(‘config’);
module.exports = function() {
const db = config.get(‘db’);
mongoose.connect(db, { useNewUrlParser: true, useUnifiedTopology: true })
.then(() => winston.info(Connected to ${db}...
));
}
My code in logging.js
const winston = require(‘winston’);
require(‘winston-mongodb’);
require(‘express-async-errors’);
const config = require(‘config’);
module.exports = function() {
winston.exceptions.handle(
new winston.transports.Console({ colorize: true, prettyPrint: true }),
new winston.transports.File({filename: ‘uncaughtExceptions.log’})
);
process.on('unhandledRejection', (ex) => {
throw ex;
});
winston.add(
new winston.transports.MongoDB({
db: 'mongodb://localhost/vidly',
level: 'error',
options: { useUnifiedTopology: true },
})
);
winston.add(new winston.transports.File({filename: 'logfile.log'}));
winston.add(new winston.transports.MongoDB({
db: 'mongodb://localhost/vidly',
level: 'info'
}));
}
Please note I am using mongoose and not MongoClient anywhere