Jump to content

yearmfew

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by yearmfew

  1. I am currently working mongodb and nodejs from w3schools website. I have seen an error in a code. 

    https://www.w3schools.com/nodejs/nodejs_mongodb_create_db.asp

    In this website there is a code for creating website. : 

    var MongoClient = require('mongodb').MongoClient;
    var url = "mongodb://localhost:27017/mydb";
    
    MongoClient.connect(url, function(err, db) {
      if (err) throw err;
      console.log("Database created!");
      db.close();
    });

    When I run this, I see this on the terminal: 

    (node:26812) 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.
    Database created!

     

    I needed to change 3rd line. 

    old 3rd line: 

    MongoClient.connect(url, function(err, db) {

    new 3rd line: 

    MongoClient.connect(url, {useUnifiedTopology: true}, function(err, db) {

     

×
×
  • Create New...