WARNING mongodb repair

problem

Node.js prompted mongoose MongoDB database connection module (node: 12580) 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. solutions

the require Mongoose = const ( 'Mongoose'); 
the let mongoose.connect DB = ( 'MongoDB: // localhost / HD15'); 
mongoose.connection.on ( "error", function (error) { 
    the console.log ( "Database Connectivity failed: "+ error); 
}); 
mongoose.connection.on (" Open ", function () { 
    the console.log (" ------ ------ database connection success! "); 
}) ;

 

solve

the require Mongoose = const ( 'Mongoose'); 
// 27017 MongoDB database default port number is 
the let mongoose.connect DB = ( 'MongoDB: // localhost: 27017 / HD15', {useNewUrlParser: to true}); 

mongoose.connection.on ( "error", function (error) { 
    the console.log ( "database connection failed:" + error); 
}); 
mongoose.connection.on ( "Open", function () { 
    the console.log ( "---- - database connection successful ------ ");! 
});

 

Guess you like

Origin www.cnblogs.com/kinblog/p/10951553.html