摘要: const { User } = require('../../model/user'); const user = require('../../model/user'); module.exports = async(req, res) => { let page = req.query.pag 阅读全文
posted @ 2020-06-12 20:31 EricBlog 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 添加字段验证 //引入 joi 模块 const Joi = require('joi'); module.exports = async(req, res) => { // 定义规则对象 const schema = { username: Joi.string().min(2).max(12). 阅读全文
posted @ 2020-06-12 15:51 EricBlog 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2020-06-12 15:15 EricBlog 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2020-06-12 14:46 EricBlog 阅读(84) 评论(0) 推荐(0) 编辑
摘要: // 引入body-parser 模块 用来处理 post 请求参数 const bodyParser = require('body-parser'); // 处理post 请求参数 app.use(bodyParser.urlencoded({extended:false})) npm inst 阅读全文
posted @ 2020-06-12 14:39 EricBlog 阅读(63) 评论(0) 推荐(0) 编辑
摘要: // 引入mongoose 第三方模块 const mongoose = require('mongoose'); // 连接数据库 mongoose.connect('mongodb://localhost/blog', { useNewUrlParser: true, useUnifiedTop 阅读全文
posted @ 2020-06-12 13:11 EricBlog 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 2 生成json文件npm init -y 3 安装项目所需模块npm install express mongoose art-template express-art-template // 引入 express 框架 const express = require('express'); // 阅读全文
posted @ 2020-06-12 10:58 EricBlog 阅读(174) 评论(0) 推荐(0) 编辑