摘要: ./model/db.js // 引入mongoose const mongoose = require("mongoose"); //解决index索引引起的弃用提醒:(node:13616) DeprecationWarning: collection.ensureIndex is deprec 阅读全文
posted @ 2021-01-17 23:31 半遮 阅读(267) 评论(0) 推荐(0) 编辑
摘要: // es5 function person() { console.log("1:pe1"); //实例化一次就会执行一遍该函数, this.run = function () { //实例方法,需要实例化后才能通过实例化对象来调用 console.log("2:run"); console.lo 阅读全文
posted @ 2021-01-17 22:48 半遮 阅读(249) 评论(0) 推荐(0) 编辑
摘要: ./model/user.js /* mongoose 的自定义修饰符: Getters 与 setters 除了mongoose内置修饰符以外,还可以通过 set (建议使用) 修饰符,对增加数据的时,对数据进行格式化; 也可以通过 get(不建议使用)在 实例获取数据 的时候 对 实例数据 进行 阅读全文
posted @ 2021-01-12 11:57 半遮 阅读(138) 评论(0) 推荐(0) 编辑
摘要: // mongoose 默认参数、 mongoose 模块化 、 mongoose 性能疑问 // mongoose 默认参数 :增加数据时候,如果不传入数据,会使用默认配置的数据 const mongoose = require("mongoose"); mongoose.connect("mon 阅读全文
posted @ 2021-01-07 16:52 半遮 阅读(173) 评论(0) 推荐(0) 编辑
摘要: mongoose01.js : /* mongoose 的使用: 1、npm 安装 mongoose : npm i mongoose --save ; 2、引入 mongoose 并连接数据库: const mongoose = require('mongoose'); mongoose.conn 阅读全文
posted @ 2021-01-06 14:56 半遮 阅读(266) 评论(0) 推荐(0) 编辑
摘要: 多文件上传: views/admin/user/add.html : <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, i 阅读全文
posted @ 2021-01-05 18:05 半遮 阅读(478) 评论(0) 推荐(0) 编辑
摘要: 单文件上传 目录: nav/add.html : <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-sca 阅读全文
posted @ 2021-01-05 12:30 半遮 阅读(141) 评论(0) 推荐(0) 编辑
摘要: package.json 文件 { "name": "express07", "version": "1.0.0", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, " 阅读全文
posted @ 2020-12-15 15:55 半遮 阅读(249) 评论(0) 推荐(0) 编辑
摘要: const express = require("express"); const app = express(); const cookieParser = require("cookie-parser"); // 配置 cookiparser 中间件 app.use(cookieParser(" 阅读全文
posted @ 2020-12-13 13:43 半遮 阅读(114) 评论(0) 推荐(0) 编辑
摘要: const express = require("express"); const app = express(); const cookieParser = require("cookie-parser"); // 配置 cookiparser 中间件 app.use(cookieParser(" 阅读全文
posted @ 2020-12-13 13:41 半遮 阅读(163) 评论(0) 推荐(0) 编辑