首页 > 解决方案 > 找不到 Company#companyTypesLinks 的实体元数据。检查您是否指定了正确的实体对象

问题描述

我的实体关系有问题,我已经尝试了所有方法,但仍然遇到同样的问题,这是我的脚本:

公司实体.ts

export class Company extends AppBaseEntity {
  @Column('text', { name: 'nom', nullable: true })
  nom: string;
  @Column('varchar', { name: 'type_entite', length: 255, nullable: true })
  typeEntite?: CompanyEntityType;
  @Column('text', { name: 'note', nullable: true })
  note: string;

  @Column('varchar', { name: 'color', length: 15, nullable: true })
  color?: string;

  @Column('text', { name: 'textMailInvoices', nullable: true })
  textMailInvoices?: string;
  @Column('varchar', { name: 'subjectMailInvoices', length: 255, nullable: true })
  subjectMailInvoices?: string;
  @Column('tinyint', { name: 'archived', nullable: false, default: 0 })
  archived: boolean;

  @OneToMany(() => CompanyTypesLinks, companyTypesLink => companyTypesLink.company, { cascade: true, onUpdate: 'CASCADE' })
  public companyTypesLinks?: CompanyTypesLinks[];

和公司类型-link.entity.ts

export class CompanyTypesLinks extends AppBaseEntity {
    @Column('varchar', { name: 'typesId', length: 36, nullable: true })
    typesId: string;

    @ManyToOne(() => Company, company => company.companyTypesLinks, { cascade: true })
    @JoinColumn({ name: 'companyId' })
    public company?: Company;

    @Column('varchar', { name: 'companyId', length: 36, nullable: true })
    companyId: string;

    @ManyToOne(() => CompanyTypes, companyTypes => companyTypes.companyTypesLinks)
    @JoinColumn({ name: 'typesId' })
    companyType?: CompanyTypes;

AppBaseEntity 包含 id

标签: typescripttypeorm

解决方案


我通过重命名公司类型链接文件解决了这个问题,实际上该文件是:

company-type-link.ts 而不是

公司类型-link.entity.ts

缺少实体术语


推荐阅读