moogodb 创建数据create 查找 find 验证 type 与 集合关联 mongoose.Schema.Types
数据库连接
// 引入mongoose第三方模块 用来操作数据库
const mongoose = require(‘mongoose’);
// 数据库连接
mongoose.connect(‘mongodb://localhost/playground’, { useNewUrlParser: true})
// 连接成功
.then(() => console.log(‘数据库连接成功’))
// 连接失败
.catch(err => console.log(err, ‘数据库连接失败’)
原创
2020-05-26 20:26:59 ·
554 阅读 ·
0 评论