const mongoose=require('mongoose');
mongoose.connect('mongodb://localhost/playground',{useNewUrlParser:true,useUnifiedTopology: true } )
.then(()=>{console.log('数据库连接成功');})
.catch((err)=>{console.log(err,'数据库连接失败');});
const mongoose=require('mongoose');
mongoose.connect('mongodb://localhost/playground',{useNewUrlParser:true,useUnifiedTopology: true } )
.then(()=>{console.log('数据库连接成功');})
.catch((err)=>{console.log(err,'数据库连接失败');});
const courseschema = new mongoose.Schema({
name: String,
author:String,
ispublish:Boolean
});
const Course = mongoose.model('Course',courseschema)
const course1= new Course({
name:'Eille',
author:`hk${400+16}`,
ispublish:true
})
course1.save();
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/ad467f5fc62344bafc3e948682bdb920.jpeg)