前端学习(1344):用户的增删改查操作1
生活随笔
收集整理的這篇文章主要介紹了
前端学习(1344):用户的增删改查操作1
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
const http = require('http');
const mongoose = require('mongoose');//數(shù)據(jù)庫連接
mongoose.connect('mongodb://localhost/playground', { useUnifiedTopology: true }).then(() => console.log('數(shù)據(jù)庫連接成功')).catch(() => console.log('數(shù)據(jù)庫連接失敗'));const userSchema = new mongoose.Schema({name: {type: String,required: true,minlength: 2,maxlength: 20},age: {type: Number,min: 18,max: 80},password: String,email: String,hobbies: [String]
});
const User = mongoose.model('User', userSchema);
//為服務(wù)器對象添加請求事件
const app = http.createServer();
app.on('request', (req, res) => {res.end('ok');
})
app.listen(3000);
運(yùn)行結(jié)果
總結(jié)
以上是生活随笔為你收集整理的前端学习(1344):用户的增删改查操作1的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 前端学习(1348):用户的增删改查操作
- 下一篇: lin接口 连接计算机,db9接口(li