【发布时间】:2022-01-06 16:48:36
【问题描述】:
考虑如下基础实体:
export abstract class Notification {
@PrimaryGeneratedColumn()
id: number;
@Column({type: "date",nullable: false})
seenAt: Date;
@Column({ type: "integer", nullable: false })
priority: number;
}
还有两个子实体如下:
@Entity()
export class NotificationType1 extends Notification {}
和
@Entity()
export class NotificationType2 extends Notification {}
有没有办法像这样使用对父类的查询来查找 NotificationType1 和 NotificationType2 中的所有行?
SELECT * FROM NOTIFICATION;
此查询返回 0 行,尽管 NotificationType1 和 NotificationType2 表中有记录。
【问题讨论】:
标签: nestjs typeorm class-table-inheritance