b
bg7zag 的博客
cqcqcq,这里是BG7ZAG,会coding的HAM,分享生活趣事、建站技术、前端开发、汽车相关、deepin系统、业余无线电等!73!
bg7zag · 注册于 2026-09-17 · 457 博文 · 0 帖子 · 0 回复
筛选: 标签「Mongoose」 ✕ 清除
Mongoose二级连表查询
首先定义两个Schema,然后 model ; DB.js 1. // 分类 2. let CategorieSchema = new mongoose.Schema({ 3. "name" : String, 4. "img" : String, 5. "date": Date 6. }...
Mongoose 分页
Mongoose 分页查询: 在Schema中创建静态方法: 1. // 分页 2. CategorieSchema.statics = { 3. fetch(id, cb) { 4. if (id) { 5. return this.find({'_id': {"$lt": id...
mongoose SchemaFactory 设置createdAt、updatedAt为时间戳
``` @Schema({ timestamps: { currentTime: () => Date.now(), // 根据官方文档写法 }, }) export class Schema extends Document { ... @Prop() createdAt: number; //...