我想为 TypeORM 实体创建一个编辑表,其中所有列都可以为空。这用于建议对最终表进行更新,并且将有 UI 允许用户接受或拒绝编辑。
我很难弄清楚如何覆盖选项@Column以使其成为可能。表达这一点的最佳方式是什么?
这是我尝试从 a 继承的方法BaseProfileEntity,但似乎不起作用:
export abstract class BaseProfileEntity {
@Column({ nullable: true })
public name!: string;
@Column({ nullable: true })
public location!: string;
}
/**
* Edit proposal to a profile. All columns should be NULLABLE. If they are not null,
* that means an edit for that column was proposed.
*/
export class ProfileEdit extends BaseProfileEntity {
@Column()
public editAuthor!: string;
}
/**
* The final profile. I want to make some columns NOT NULLABLE and add a default.
*/
export class Profile extends BaseProfileEntity {
@Column({ nullable: false, default: "" })
public name!: string;
@Column({ nullable: false })
public location!: string;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1441 次 |
| 最近记录: |