mongoose 連接數據庫報錯的解決方案

報錯信息如下

     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.

大意就是說:當前的URL字符串解析器被棄用然後也提供瞭解決方案 讓你在選項裏面{useNewUrlParser: true}

代碼如下:

mongoose.connect('mongodb://user:[email protected]:port/dbname', { useNewUrlParser: true })

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章