问题描述:
DeprecationWarning: current URL string parser is deprecated, and will be removed in a future versio n. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
解决方法:
var mongoose = require('mongoose'); DB_URL = 'mongodb://xxxx:27017/db_name'; /** * 连接 */ mongoose.connect(DB_URL,{ useNewUrlParser: true });
1
2
3
4
5
6
7
8
|
var
mongoose
=
require
(
'mongoose'
)
;
DB_URL
=
'mongodb://xxxx:27017/db_name'
;
/
*
*
*
连接
*
/
mongoose
.
connect
(
DB_URL
,
{
useNewUrlParser
:
true
}
)
;
|
加入 { useNewUrlParser: true }
则不再提示 DeprecationWarning: current URL string parser is deprecated, and will be removed in a future versio
n. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.