摘要: Proxy代理对象 let person = { name: "zf", get aliasName() { //属性访问器 return this.name + "jg"; }, }; 使用 Proxy 代理 const proxy = new Proxy(person, { get(target 阅读全文
posted @ 2022-06-25 11:25 霸哥yyds 阅读(84) 评论(0) 推荐(0) 编辑
摘要: 模型 db.js // 连接数据库 const mongoose = require('mongoose') // eggadmin 用户名 // 123456 密码 // 127.0.0.1:27017 服务器及端口 // eggcms 数据库 mongoose.connect('mongodb: 阅读全文
posted @ 2022-06-12 09:39 霸哥yyds 阅读(47) 评论(0) 推荐(0) 编辑
摘要: 定义文档结构 分类表 // 连接数据库 const mongoose = require('mongoose') // eggadmin 用户名 // 123456 密码 // 127.0.0.1:27017 服务器及端口 // eggcms 数据库 mongoose.connect('mongod 阅读全文
posted @ 2022-06-11 21:22 霸哥yyds 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 定义 Schema const OrderSchema = mongoose.Schema({ order_id: String, uid: Number, trade_no: String, all_price: Number, all_num: Number }) const OrderItem 阅读全文
posted @ 2022-06-03 10:57 霸哥yyds 阅读(71) 评论(0) 推荐(0) 编辑
摘要: 内置数据校验方法 required 表示这个数据必须传入 max 用于 Number 类型数据 最大值 min 用于 Number 类型数据 最小值 enum 枚举类型 要求数据必须满足枚举值 match 增加的数据必须符合 match(正则) 的规则 maxlength 最大值 minlength 阅读全文
posted @ 2022-06-02 22:02 霸哥yyds 阅读(56) 评论(0) 推荐(0) 编辑
摘要: 添加索引 const UserSchema = mongoose.Schema({ name: { type: String }, sn: { type: String, index: true, // 添加索引 }, age: Number, status: { type: Number, def 阅读全文
posted @ 2022-06-02 21:36 霸哥yyds 阅读(50) 评论(0) 推荐(0) 编辑
摘要: 默认参数 const mongoose = require('mongoose') // eggadmin 用户名 // 123456 密码 // 127.0.0.1:27017 服务器及端口 // eggcms 数据库 mongoose.connect('mongodb://eggadmin:12 阅读全文
posted @ 2022-06-02 21:09 霸哥yyds 阅读(30) 评论(0) 推荐(0) 编辑
摘要: 安装 npm install mongoose --save 配置 const mongoose = require('mongoose') // eggadmin 用户名 // 123456 密码 // 127.0.0.1:27017 服务器及端口 // eggcms 数据库 mongoose.c 阅读全文
posted @ 2022-06-02 12:27 霸哥yyds 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 管道操作符 $project 增加、删除、重命名字段 (可以筛选指定的字段出现) $match 条件匹配,只有满足条件的文档才能进入下一个阶段 $limit 限制结果的数量 $skip 跳过文档的数量 $sort 条件排序 $group 条件组合结果 $lookup 可以引入其他集合的数据 插入数据 阅读全文
posted @ 2022-06-02 11:14 霸哥yyds 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 创建超级管理员账户 use admin db.createUser({ user: "admin", pwd: "123456", roles: [ {role: "root", db: "admin"} ] }) 修改 Mongodb 数据库配置文件 MongoDB/Server/5.0/bin/ 阅读全文
posted @ 2022-06-01 21:31 霸哥yyds 阅读(199) 评论(0) 推荐(0) 编辑