frans 參考文章

關於警告 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. 的正確解決方法如下:

添加 {useNewUrlParser:true}

var MongoClient = require('mongodb').MongoClient
var url = 'mongodb://localhost:27017/testdb'// 數據庫地址
 
module.exports = {
    getDB: function (callback) {
        MongoClient.connect(url, {useNewUrlParser:true},  function (err, db) {
            callback(db)   
        })
    }
}