修改代码格式;
数据库查询加 lean 判断; 其它内容微调。
This commit is contained in:
@@ -3,13 +3,13 @@ import { prop, pre } from '@typegoose/typegoose';
|
||||
/**
|
||||
* BaseModel
|
||||
*/
|
||||
@pre<BaseModel>('save', function (next) {
|
||||
@pre<BaseModel>('save', function(next) {
|
||||
if (!this.createdAt || this.isNew) {
|
||||
this.createdAt = this.updatedAt = new Date()
|
||||
this.createdAt = this.updatedAt = new Date();
|
||||
} else {
|
||||
this.updatedAt = new Date()
|
||||
this.updatedAt = new Date();
|
||||
}
|
||||
next()
|
||||
next();
|
||||
})
|
||||
|
||||
export default class BaseModel {
|
||||
@@ -21,4 +21,4 @@ export default class BaseModel {
|
||||
|
||||
@prop()
|
||||
updatedAt: Date
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user