mongoose 连接问题

var mongoose= require('mongoose');

mongoose.connect('mongodb://localhost/chat');

这样连接报错

DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0,use `openUri()` instead, or set the `useMongoClient` option if using `connect()` or `createConnection()`


简单的解决办法:
用:

mongoose.connect('mongodb://localhost/chat',{useMongoClient:true});

替换:

mongoose.connect('mongodb://localhost/chat');即可

你可能感兴趣的:(mongoose 连接问题)