mongoose 连接警告问题(node:148572) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0
2017-07-11 10:51
387 查看
代码
var mongoose=require("mongoose"); mongoose.connect('mongodb://127.0.0.1:27017/test');//连接数据库 var connection=mongoose.connection; connection.on('error',function(err){ if(err){ console.log(err); } }); connection.on('open',function(){ console.log('opened'); });
问题
(node:148572) 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/connections.html#use-mongo-clientopened
解决
还是能出来结果的,只不过是版本更新了,连接方式有变。改成这样就行
mongoose.connect('mongodb://127.0.0.1:27017/test',{useMongoClient: true});//连接数据库
总结
刚开始看到问题所在,点进去看了mongoose的文档,无奈英文文档看不下去。于是就百度了……还是要耐下心来看英文文档
相关文章推荐
- (node:5160) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()`
- (node:31568) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` inste
- DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instea
- EF之数据库连接问题The specified named connection is either not found in the configuration, not intended to be used with the Ent
- 解决Name node is in safe mode的问题
- pip安装模块警告InsecurePlatformWarning: A true SSLContext object is not available.
- iOS - 报错 Warning: Attempt to present <xx: xx> on <xx: xx> whose view is not in the window hierarchy!
- This file is already open in an editor问题的解决方法
- python连接mysql时 出现DeprecationWarning: the sets module is deprecated 警告
- Hadoop 处理“Name node is in safe mode”问题(转)
- Android-Android studio 出现 Error: NDK integration is deprecated in the current plugin. 问题解决
- [问题记录]cString is deprecated :first deprecated in iOS 2.0
- Android-Android studio 出现 Error: NDK integration is deprecated in the current plugin. 问题解决
- Warning: require() open_basedir restriction in effect. 类似问题解决方法
- Warning: Attempt to present on whose view is not in模态跳转问题
- Hive警告的解决办法 WARNING: org.apache.hadoop.metrics.jvm.EventCounter is deprecated
- warning: Signal <> missing in the sensitivity list is added for synthesis purposes
- 打开一个源码工程提示t is already open in another workspace问题
- pip安装模块警告InsecurePlatformWarning: A true SSLContext object is not available.
- pip安装模块警告InsecurePlatformWarning: A true SSLContext object is not available.