NodeJS连接MongoDB数据库
连接数据库的js文件【我将其命名为(connect.js)】

/* 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.
【DeprecationWarning:当前URL字符串 解析器已弃用,并将在以后的版本中删除。 要使用新的解析器,请将选项{useNewUrlParser:true}传递给MongoClient.connect。】 */
入口文件【我将其命名为(app.js)】

require(‘./data/connect‘)
最后,在当前的工作目录中输入
nodemon .\app.js
当然以上的命令我是默认你安装了nodemon这个命令行工具的哈!
如果你没有安装, 那么也很简单, 你直接在当前的工作目录输入
node app.js
也可以!
可以看到我们的数据库就连接成功了!

NodeJS连接MongoDB数据库
标签:unifi code cat log 连接数据库 image client ati 效果