mosh-hamedani / vidly-api-node

309 stars 282 forks source link

URL String Parser is deprecated / Current Server Discovery and Monitoring engine #18

Closed therabithole closed 3 years ago

therabithole commented 4 years ago

(node:6448) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect. (node:6448) DeprecationWarning: 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. Done!

Turkinolith commented 4 years ago

Still an issue, also get this one now: (node:20464) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.

codingChewie commented 3 years ago

Need to update db.js in the startup directory:

from:

module.exports = function() {
  const db = config.get('db');
  mongoose.connect(db)
    .then(() => winston.info(`Connected to ${db}...`));
}

to:

module.exports = () => {
  const db = config.get('db')
  mongoose
    .connect(db, { useNewUrlParser: true, useUnifiedTopology: true })
    .then(() => winston.info(`Connected to ${db}...`))
}