我直接遵循TypeORM的文档here。
我尝试创建的实体关系如下(& R):
报告实体
@Entity({name: "reports"})
export class ReportsEntity {
@PrimaryGeneratedColumn('uuid')
uuid: string;
@PrimaryColumn()
@ManyToOne(() => ApplicationsEntity, (application) => application.reports)
application: ApplicationsEntity
@Column()
description: string
@Column({ type: 'timestamp' })
@CreateDateColumn()
createdAt: Date;
@Column({ type: 'timestamp' })
@UpdateDateColumn()
updatedAt: Date;
}
应用程序实体
@Entity({name: "applications"})
export class ApplicationsEntity {
@PrimaryGeneratedColumn('uuid')
uuid: string;
@Column()
name: string;
@Column()
description: string;
@Column({ type: 'timestamp' })
@CreateDateColumn()
createdAt: Date;
@Column({ type: 'timestamp' })
@UpdateDateColumn()
updatedAt: Date;
//Relationships
@OneToMany(() => ReportsEntity, (report) => report.application)
reports: ReportsEntity[]
}
但是,当启动时,我从MySQL中得到以下错误:
Data type "Object" in "ReportsEntity.application" is not supported by "mysql" database.
我没有看到我错过了什么或我做错了什么时,审查和比较的文件。
1条答案
按热度按时间ars1skjm1#
删除@ManyToOne上面的@PrimaryColumn(),因为它试图创建数据类型为“ApplicationsEntity”的列,mysql不支持该类型
报表实体
应用程序实体