摘要:
Proxy代理对象 let person = { name: "zf", get aliasName() { //属性访问器 return this.name + "jg"; }, }; 使用 Proxy 代理 const proxy = new Proxy(person, { get(target 阅读全文
摘要:
模型 db.js // 连接数据库 const mongoose = require('mongoose') // eggadmin 用户名 // 123456 密码 // 127.0.0.1:27017 服务器及端口 // eggcms 数据库 mongoose.connect('mongodb: 阅读全文
摘要:
定义文档结构 分类表 // 连接数据库 const mongoose = require('mongoose') // eggadmin 用户名 // 123456 密码 // 127.0.0.1:27017 服务器及端口 // eggcms 数据库 mongoose.connect('mongod 阅读全文
摘要:
定义 Schema const OrderSchema = mongoose.Schema({ order_id: String, uid: Number, trade_no: String, all_price: Number, all_num: Number }) const OrderItem 阅读全文
摘要:
内置数据校验方法 required 表示这个数据必须传入 max 用于 Number 类型数据 最大值 min 用于 Number 类型数据 最小值 enum 枚举类型 要求数据必须满足枚举值 match 增加的数据必须符合 match(正则) 的规则 maxlength 最大值 minlength 阅读全文
摘要:
添加索引 const UserSchema = mongoose.Schema({ name: { type: String }, sn: { type: String, index: true, // 添加索引 }, age: Number, status: { type: Number, def 阅读全文
摘要:
默认参数 const mongoose = require('mongoose') // eggadmin 用户名 // 123456 密码 // 127.0.0.1:27017 服务器及端口 // eggcms 数据库 mongoose.connect('mongodb://eggadmin:12 阅读全文
摘要:
安装 npm install mongoose --save 配置 const mongoose = require('mongoose') // eggadmin 用户名 // 123456 密码 // 127.0.0.1:27017 服务器及端口 // eggcms 数据库 mongoose.c 阅读全文
摘要:
管道操作符 $project 增加、删除、重命名字段 (可以筛选指定的字段出现) $match 条件匹配,只有满足条件的文档才能进入下一个阶段 $limit 限制结果的数量 $skip 跳过文档的数量 $sort 条件排序 $group 条件组合结果 $lookup 可以引入其他集合的数据 插入数据 阅读全文