在node.js中连接mongodb时,
mongoose.connect('mongodb://localhost:27018', function(error){
// 连接数据库之后的回调
if(error){
console.log('连接数据库失败');
console.log(error);
}
else{
console.log('连接数据库成功');
// 如果连接成功,就可以通过mongoose模块操作数据库
//连接成功,再启动服务
app.listen(8080);
}
});
报错 :
(node:12596) DeprecationWarning: open()
is deprecated in mongoose >= 4.11.0, use openUri()
instead, or set the useMongoClient
option if using connect()
or createConnection()
. See http://mongoosejs.com/docs/co...
连接数据库成功
(node:12596) DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/pr...
慕虎7371278
相关分类