Typeorm
作者:互联网
TypeORM 是一个ORM (opens new window)框架
Typeorm 实体 Entity
Typeorm BeforeInsert, BeforeUpdate
直接Save,并不会触发BeforeInsert和BeforeUpdate
async create(attributes: DeepPartial<T>) {
return this.repository.save(attributes); // 不会触发BeforeInsert
}
解决办法 利用new Entiry()
async create(attributes: DeepPartial<T>) {
return this.repository.save({...new User(), ...attributes});
}
标签:BeforeInsert,create,new,attributes,save,Typeorm 来源: https://www.cnblogs.com/boyGdm/p/15707636.html