摘要: 内置数据校验方法 required 表示这个数据必须传入 max 用于 Number 类型数据 最大值 min 用于 Number 类型数据 最小值 enum 枚举类型 要求数据必须满足枚举值 match 增加的数据必须符合 match(正则) 的规则 maxlength 最大值 minlength 阅读全文
posted @ 2022-06-02 22:02 霸哥yyds 阅读(75) 评论(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 阅读(63) 评论(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 阅读(61) 评论(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 阅读(204) 评论(0) 推荐(0)
摘要: 管道操作符 $project 增加、删除、重命名字段 (可以筛选指定的字段出现) $match 条件匹配,只有满足条件的文档才能进入下一个阶段 $limit 限制结果的数量 $skip 跳过文档的数量 $sort 条件排序 $group 条件组合结果 $lookup 可以引入其他集合的数据 插入数据 阅读全文
posted @ 2022-06-02 11:14 霸哥yyds 阅读(58) 评论(0) 推荐(0)