连接MongoDB
1.安装第三方模块npm install mongoose
2.创建 01.js文件在其中写入
3.启动服务
4.连接数据库
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/playground',{useUnifiedTopology: true})
.then(() => console.log('数据库连接成功'))
.catch(() => console.log(err, '数据库连接失败'))
注意:需要以管理员身份启动windows powershell ,再输入net start mongodb的命令