create-chuntianxiaozhu
Version:
春天小猪模板工具
33 lines (26 loc) • 579 B
text/typescript
import {
BeforeInsert,
BeforeUpdate,
Column,
PrimaryGeneratedColumn,
} from 'typeorm';
export class BaseEntity<T> {
()
id: number;
({ name: 'create_date', type: 'bigint' })
createDate: number;
({ name: 'update_date', type: 'bigint' })
updateDate: number;
()
beforeInsert() {
this.createDate = Date.now();
this.updateDate = Date.now();
}
()
beforeUpdate() {
this.updateDate = Date.now();
}
constructor(partial: Partial<T>) {
Object.assign(this, partial);
}
}